extractors_test.go — fiber Source File
Architecture documentation for extractors_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR cf5e296e_8db5_6f84_b05a_9c0cac6f83e7["extractors_test.go"] cc7104af_aece_1fe5_3985_791c7f34910c["context"] cf5e296e_8db5_6f84_b05a_9c0cac6f83e7 --> cc7104af_aece_1fe5_3985_791c7f34910c style cf5e296e_8db5_6f84_b05a_9c0cac6f83e7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package extractors
import (
"context"
"net/http"
"strings"
"testing"
"github.com/gofiber/fiber/v3"
"github.com/stretchr/testify/require"
"github.com/valyala/fasthttp"
)
// go test -run Test_Extractors_Missing
func Test_Extractors_Missing(t *testing.T) {
t.Parallel()
app := fiber.New()
// Add a route to test the missing param
app.Get("/test", func(c fiber.Ctx) error {
token, err := FromParam("token").Extract(c)
require.Empty(t, token)
require.ErrorIs(t, err, ErrNotFound)
return nil
})
_, err := app.Test(newRequest(fiber.MethodGet, "/test"))
require.NoError(t, err)
ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
t.Cleanup(func() { app.ReleaseCtx(ctx) })
// Missing form
token, err := FromForm("token").Extract(ctx)
require.Empty(t, token)
require.ErrorIs(t, err, ErrNotFound)
// Missing query
token, err = FromQuery("token").Extract(ctx)
require.Empty(t, token)
require.ErrorIs(t, err, ErrNotFound)
// Missing header
token, err = FromHeader("X-Token").Extract(ctx)
require.Empty(t, token)
require.ErrorIs(t, err, ErrNotFound)
// Missing Auth header
token, err = FromAuthHeader("Bearer").Extract(ctx)
require.Empty(t, token)
require.ErrorIs(t, err, ErrNotFound)
// Missing cookie
token, err = FromCookie("token").Extract(ctx)
require.Empty(t, token)
require.ErrorIs(t, err, ErrNotFound)
}
// newRequest creates a new *http.Request for Fiber's app.Test
func newRequest(method, target string) *http.Request {
req, err := http.NewRequestWithContext(context.Background(), method, target, http.NoBody)
// ... (880 more lines)
Domain
Subdomains
Functions
- Test_Extractor_Chain()
- Test_Extractor_Chain_AllErrors()
- Test_Extractor_Chain_Error_Propagation()
- Test_Extractor_Chain_Introspection()
- Test_Extractor_Chain_MixedScenarios()
- Test_Extractor_Chain_NilFunctions()
- Test_Extractor_Chain_With_Success()
- Test_Extractor_FromAuthHeader_CustomScheme()
- Test_Extractor_FromAuthHeader_EdgeCases()
- Test_Extractor_FromAuthHeader_NoScheme()
- Test_Extractor_FromAuthHeader_RFC_Compliance()
- Test_Extractor_FromAuthHeader_Token68_Validation()
- Test_Extractor_FromAuthHeader_WhitespaceToken()
- Test_Extractor_FromCustom()
- Test_Extractor_SourceTypes()
- Test_Extractor_URL_Encoded()
- Test_Extractors()
- Test_Extractors_Missing()
- Test_isValidToken68()
- newRequest()
Classes
Types
Dependencies
- context
Source
Frequently Asked Questions
What does extractors_test.go do?
extractors_test.go is a source file in the fiber codebase, written in go. It belongs to the DataBinding domain, Extractors subdomain.
What functions are defined in extractors_test.go?
extractors_test.go defines 20 function(s): Test_Extractor_Chain, Test_Extractor_Chain_AllErrors, Test_Extractor_Chain_Error_Propagation, Test_Extractor_Chain_Introspection, Test_Extractor_Chain_MixedScenarios, Test_Extractor_Chain_NilFunctions, Test_Extractor_Chain_With_Success, Test_Extractor_FromAuthHeader_CustomScheme, Test_Extractor_FromAuthHeader_EdgeCases, Test_Extractor_FromAuthHeader_NoScheme, and 10 more.
What does extractors_test.go depend on?
extractors_test.go imports 1 module(s): context.
Where is extractors_test.go in the architecture?
extractors_test.go is located at extractors/extractors_test.go (domain: DataBinding, subdomain: Extractors, directory: extractors).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free