Home / Function/ Test_App_Use_StrictRoutingBoundary() — fiber Function Reference

Test_App_Use_StrictRoutingBoundary() — fiber Function Reference

Architecture documentation for the Test_App_Use_StrictRoutingBoundary() function in router_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  937ac419_bd90_f30d_f8bd_471839c9d7ac["Test_App_Use_StrictRoutingBoundary()"]
  326d7e00_9e4f_d854_0c78_b9c0c93e5537["router_test.go"]
  937ac419_bd90_f30d_f8bd_471839c9d7ac -->|defined in| 326d7e00_9e4f_d854_0c78_b9c0c93e5537
  style 937ac419_bd90_f30d_f8bd_471839c9d7ac fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

router_test.go lines 1021–1105

func Test_App_Use_StrictRoutingBoundary(t *testing.T) {
	type testCase struct {
		name           string
		path           string
		expectedStatus int
		strictRouting  bool
		expectMatched  bool
	}

	testCases := []testCase{
		{
			name:           "Strict exact match",
			strictRouting:  true,
			path:           "/api",
			expectMatched:  true,
			expectedStatus: StatusOK,
		},
		{
			name:           "Strict trailing slash partial",
			strictRouting:  true,
			path:           "/api/",
			expectMatched:  true,
			expectedStatus: StatusOK,
		},
		{
			name:           "Strict nested partial",
			strictRouting:  true,
			path:           "/api/users",
			expectMatched:  true,
			expectedStatus: StatusOK,
		},
		{
			name:           "Strict disallows sibling prefix",
			strictRouting:  true,
			path:           "/apiv1",
			expectMatched:  false,
			expectedStatus: StatusNotFound,
		},
		{
			name:           "Non-strict exact match",
			strictRouting:  false,
			path:           "/api",
			expectMatched:  true,
			expectedStatus: StatusOK,
		},
		{
			name:           "Non-strict trailing slash partial",
			strictRouting:  false,
			path:           "/api/",
			expectMatched:  true,
			expectedStatus: StatusOK,
		},
		{
			name:           "Non-strict nested partial",
			strictRouting:  false,
			path:           "/api/users",
			expectMatched:  true,
			expectedStatus: StatusOK,
		},
		{
			name:           "Non-strict disallows sibling prefix",
			strictRouting:  false,
			path:           "/apiv1",
			expectMatched:  false,
			expectedStatus: StatusNotFound,
		},
	}

	for _, tt := range testCases {
		t.Run(tt.name, func(t *testing.T) {
			app := New(Config{StrictRouting: tt.strictRouting})

			matched := false
			app.Use("/api", func(c Ctx) error {
				matched = true
				return c.SendStatus(StatusOK)
			})

			resp, err := app.Test(httptest.NewRequest(MethodGet, tt.path, http.NoBody))
			require.NoError(t, err)
			require.Equal(t, tt.expectedStatus, resp.StatusCode)

Domain

Subdomains

Defined In

Frequently Asked Questions

What does Test_App_Use_StrictRoutingBoundary() do?
Test_App_Use_StrictRoutingBoundary() is a function in the fiber codebase, defined in router_test.go.
Where is Test_App_Use_StrictRoutingBoundary() defined?
Test_App_Use_StrictRoutingBoundary() is defined in router_test.go at line 1021.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free