MCPcopy
hub / github.com/gofiber/fiber / Test_Domain_RouteChainAllMethods

Function Test_Domain_RouteChainAllMethods

domain_test.go:1031–1073  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1029}
1030
1031func Test_Domain_RouteChainAllMethods(t *testing.T) {
1032 t.Parallel()
1033
1034 app := New()
1035
1036 rc := app.Domain("api.example.com").RouteChain("/test")
1037 rc.All(func(c Ctx) error {
1038 c.Set("X-All", "yes")
1039 return c.Next()
1040 })
1041 rc.Head(func(c Ctx) error {
1042 return c.SendStatus(StatusOK)
1043 })
1044 rc.Put(func(c Ctx) error {
1045 return c.SendString("put")
1046 })
1047 rc.Delete(func(c Ctx) error {
1048 return c.SendString("delete")
1049 })
1050 rc.Connect(func(c Ctx) error {
1051 return c.SendString("connect")
1052 })
1053 rc.Options(func(c Ctx) error {
1054 return c.SendString("options")
1055 })
1056 rc.Trace(func(c Ctx) error {
1057 return c.SendString("trace")
1058 })
1059 rc.Patch(func(c Ctx) error {
1060 return c.SendString("patch")
1061 })
1062 rc.Query(func(c Ctx) error {
1063 return c.SendString("query")
1064 })
1065
1066 for _, method := range []string{MethodPut, MethodDelete, MethodPatch, MethodOptions, MethodQuery} {
1067 req := httptest.NewRequest(method, "/test", http.NoBody)
1068 req.Host = "api.example.com"
1069 resp, err := app.Test(req)
1070 require.NoError(t, err)
1071 require.Equal(t, StatusOK, resp.StatusCode)
1072 }
1073}
1074
1075func Test_parseDomainPattern(t *testing.T) {
1076 t.Parallel()

Callers

nothing calls this directly

Calls 15

TestMethod · 0.80
NewFunction · 0.70
RouteChainMethod · 0.65
DomainMethod · 0.65
AllMethod · 0.65
SetMethod · 0.65
NextMethod · 0.65
HeadMethod · 0.65
SendStatusMethod · 0.65
PutMethod · 0.65
SendStringMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected