Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface {
// JSON sends a JSON response with the specified status code.
JSON(statusCode int, obj interface{})
// String sends a formatted string response with the specified status code.
String(statusCode int, format string, values ...interface{})
// Param retrieves a route parameter by name.
Param(key string) string
// Query retrieves a query parameter by name.
Query(key string) string
// ShouldBindJSON parses the request body as JSON into the given object.
ShouldBindJSON(obj interface{}) error
// ShouldBindBodyWithJSON is a shortcut for c.ShouldBindBodyWith(obj, binding.JSON).
ShouldBindBodyWithJSON(obj any) error
// ShouldBindBodyWithXML is a shortcut for c.ShouldBindBodyWith(obj, binding.XML).
ShouldBindBodyWithXML(obj any) error
// ShouldBindBodyWithYAML is a shortcut for c.ShouldBindBodyWith(obj, binding.YAML).
ShouldBindBodyWithYAML(obj any) error
// ShouldBindBodyWithTOML is a shortcut for c.ShouldBindBodyWith(obj, binding.TOML).
ShouldBindBodyWithTOML(obj any) error
// Next executes the next handler in the middleware chain.
Next()
// Request returns the underlying HTTP request.
Request() *http.Request
// ClientIP returns the client's IP address.
ClientIP() string
// SetHeader sets a header in the response.
SetHeader(key, value string)
// Get retrieves a value from the context by key.
Get(key string) (value any, exists bool)
// Set sets a key-value pair in the context.
Set(key string, value any)
// AbortWithStatus aborts the request with the specified status code.
AbortWithStatus(code int)
// Abort aborts the request.
Abort()
}
Context abstracts the HTTP context used by the framework.
func NewGinContext ¶
NewGinContext wraps Gin's context and returns a new ginContext.
type HTTPServer ¶
type HTTPServer interface {
RouterGroup
transport.Server
}
Server defines the abstraction for the web server.
func NewHTTPServer ¶
func NewHTTPServer(opts ...Option) HTTPServer
NewGinEngine creates a new Gin-based engine with the provided options.
type HandlerFunc ¶
type HandlerFunc func(ctx Context)
HandlerFunc defines a generic HTTP handler function type.
type Option ¶
type Option func(*Options)
func WithAddress ¶
WithAddress sets the address for the server
func WithMiddleware ¶
func WithMiddleware(middleware ...HandlerFunc) Option
WithMiddleware adds middleware to the server
func WithShutdownTimeout ¶
WithShutdownTimeout sets the shutdown timeout for the server
type Options ¶
type Options struct {
Address string
Mode string
ShutdownTimeout time.Duration
Middleware []HandlerFunc
Logger gin.HandlerFunc // Custom logger middleware
}
Options contains configurable settings for the Gin web server
type Routable ¶
type Routable interface {
RegisterRoutes(router RouterGroup)
}
Routable is an optional interface that modules can implement to register HTTP routes.
type Router ¶
type Router interface {
GET(route string, handler HandlerFunc)
POST(route string, handler HandlerFunc)
PUT(route string, handler HandlerFunc)
PATCH(route string, handler HandlerFunc)
DELETE(route string, handler HandlerFunc)
OPTIONS(route string, handler HandlerFunc)
HEAD(route string, handler HandlerFunc)
}
Router defines the core HTTP routing interface.
type RouterGroup ¶
type RouterGroup interface {
Router
// Group creates a new RouterGroup with the given prefix.
Group(prefix string) RouterGroup
Use(middleware ...HandlerFunc)
}
RouterGroup abstracts route grouping; it embeds Router.