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

Function Test_Integration_Domain_CaseInsensitiveMatching

app_integration_test.go:1067–1097  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1065}
1066
1067func Test_Integration_Domain_CaseInsensitiveMatching(t *testing.T) {
1068 t.Parallel()
1069
1070 app := fiber.New()
1071
1072 app.Domain("API.Example.COM").Get("/", func(c fiber.Ctx) error {
1073 return c.SendString("matched")
1074 })
1075
1076 // Test various case combinations
1077 hosts := []string{
1078 "api.example.com",
1079 "API.EXAMPLE.COM",
1080 "Api.Example.Com",
1081 "aPi.eXaMpLe.CoM",
1082 }
1083
1084 for _, host := range hosts {
1085 t.Run(host, func(t *testing.T) {
1086 t.Parallel()
1087 req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
1088 req.Host = host
1089 resp, err := app.Test(req)
1090 require.NoError(t, err)
1091 require.Equal(t, fiber.StatusOK, resp.StatusCode)
1092 body, err := io.ReadAll(resp.Body)
1093 require.NoError(t, err)
1094 require.Equal(t, "matched", string(body))
1095 })
1096 }
1097}
1098
1099func Test_Integration_Domain_ReusableSubApp(t *testing.T) {
1100 t.Parallel()

Callers

nothing calls this directly

Calls 5

TestMethod · 0.80
NewMethod · 0.65
GetMethod · 0.65
DomainMethod · 0.65
SendStringMethod · 0.65

Tested by

no test coverage detected