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)
| 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. |
| 895 | func 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. |