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
// BindJSON parses the request body as JSON into the given object.
BindJSON(obj interface{}) 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)
}
Context abstracts the HTTP context used by the framework.
type HTTPServer ¶
type HTTPServer interface {
RouterGroup
// Use registers middleware handlers.
Use(middleware ...HandlerFunc)
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
}
RouterGroup abstracts route grouping; it embeds Router.