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

Function Params

req.go:895–901  ·  view source on GitHub ↗

Params is used to get the route parameters. This function is generic and can handle different route parameters type values. If the generic type cannot be matched to a supported type, the function returns the default value (if provided) or the zero value of type V. Example: http://example.com/user/

(c Ctx, key string, defaultValue ...V)

Source from the content-addressed store, hash-verified

893// http://example.com/id/:number -> http://example.com/id/john
894// Params[int](c, "number", 0) -> returns 0 because can't parse 'john' as integer.
895func Params[V GenericType](c Ctx, key string, defaultValue ...V) V {
896 v, err := genericParseType[V](c.Params(key))
897 if err != nil && len(defaultValue) > 0 {
898 return defaultValue[0]
899 }
900 return v
901}
902
903// Scheme contains the request protocol string: http or https for TLS requests.
904// Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.

Callers 1

Test_Ctx_ParamsFunction · 0.85

Calls 1

ParamsMethod · 0.65

Tested by 1

Test_Ctx_ParamsFunction · 0.68