server

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindJSON

func BindJSON[T any](ctx *gin.Context) (T, error)

func BindRequest

func BindRequest[T any](ctx *gin.Context, bindType binding.Binding) (T, error)

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

func GetAndParseFromContext[T any](ctx *gin.Context, key string) (T, error)

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

func GetFromContext[T any](ctx *gin.Context, key string) (T, error)

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

func GetPathParam[T any](ctx *gin.Context, key string) (T, bool, error)

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

func GetRequiredPathParam[T any](ctx *gin.Context, key string) (T, error)

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.

func Handler

func Handler(handlerName string, successCode int, handler func(ctx *gin.Context) (any, error)) gin.HandlerFunc

Types

type Http

type Http struct {
	// contains filtered or unexported fields
}

func New

func New(srv *http.Server, timeout time.Duration, logger ezutil.Logger, shutdownFunc func() error) *Http

func (*Http) ServeGracefully

func (hs *Http) ServeGracefully()

ServeGracefully starts the HTTP server and handles graceful shutdown

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL