(t *testing.T)
| 1953 | } |
| 1954 | |
| 1955 | func Test_NextCustom_MethodNotAllowed(t *testing.T) { |
| 1956 | t.Parallel() |
| 1957 | app := newCustomApp() |
| 1958 | app.Get("/foo", func(c Ctx) error { return c.SendStatus(StatusOK) }) |
| 1959 | useRoute := &Route{use: true, path: "/foo", Path: "/foo", routeParser: parseRoute("/foo", regexp.MustCompile)} |
| 1960 | m := app.methodInt(MethodGet) |
| 1961 | app.stack[m] = append([]*Route{useRoute}, app.stack[m]...) |
| 1962 | app.hasRoutesRefreshed = true |
| 1963 | app.ensureAutoHeadRoutes() |
| 1964 | app.RebuildTree() |
| 1965 | |
| 1966 | fctx := &fasthttp.RequestCtx{} |
| 1967 | fctx.Request.Header.SetMethod(MethodPost) |
| 1968 | fctx.Request.SetRequestURI("/foo") |
| 1969 | |
| 1970 | ctx := app.AcquireCtx(fctx) |
| 1971 | defer app.ReleaseCtx(ctx) |
| 1972 | |
| 1973 | matched, err := app.nextCustom(ctx) |
| 1974 | require.False(t, matched) |
| 1975 | require.ErrorIs(t, err, ErrMethodNotAllowed) |
| 1976 | allow := string(ctx.Response().Header.Peek(HeaderAllow)) |
| 1977 | require.Equal(t, "GET, HEAD", allow) |
| 1978 | } |
| 1979 | |
| 1980 | func Test_NextCustom_SkipNonUseRoutesSkipsFallback(t *testing.T) { |
| 1981 | t.Parallel() |
nothing calls this directly
no test coverage detected