Documentation
¶
Index ¶
- func BindJSON[T any](ctx *gin.Context) (T, error)
- func BindRequest[T any](ctx *gin.Context, bindType binding.Binding) (T, error)
- func GetAndParseFromContext[T any](ctx *gin.Context, key string) (T, error)
- func GetFromContext[T any](ctx *gin.Context, key string) (T, error)
- func GetPathParam[T any](ctx *gin.Context, key string) (T, bool, error)
- func GetRequiredPathParam[T any](ctx *gin.Context, key string) (T, error)
- func Handler(handlerName string, successCode int, ...) gin.HandlerFunc
- type Http
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindRequest ¶
BindRequest binds the incoming HTTP request to a struct of type T using the specified binding type. It supports various Gin binding types such as JSON, XML, Query, etc. Returns the bound struct or an error if binding fails.
func GetAndParseFromContext ¶
GetAndParseFromContext retrieves a string value from the Gin context and parses it to type T. It combines GetFromContext and Parse operations in a single function call. Returns the parsed value or an error if the key doesn't exist or parsing fails.
func GetFromContext ¶
GetFromContext retrieves a value from the Gin context and type-asserts it to type T. Returns the typed value or an error if the key does not exist or type assertion fails. Useful for retrieving typed data stored in context by middleware.
func GetPathParam ¶
GetPathParam extracts and parses a path parameter from the Gin context. It returns the parsed value of type T, a boolean indicating if the parameter exists, and an error if parsing fails. If the parameter does not exist, it returns the zero value with false. Supports parsing to string, int, bool, and UUID types.
func GetRequiredPathParam ¶
GetRequiredPathParam extracts and parses a required path parameter from the Gin context. It returns the parsed value of type T or an error if the parameter is missing or parsing fails. Unlike GetPathParam, this function treats missing parameters as an error condition.