Documentation
¶
Overview ¶
Package gin provides a Gin implementation of the HTTP server abstraction.
Package gin provides a Gin implementation of the HTTP server abstraction.
Package gin provides a Gin implementation of the HTTP server abstraction.
Index ¶
- func NewErrorHandlerMiddleware() middleware.IErrorHandlerMiddleware
- func NewLoggingMiddleware() core.ILoggingMiddleware
- type Context
- func (c *Context) Abort()
- func (c *Context) Bind(obj interface{}) error
- func (c *Context) BindJSON(obj interface{}) error
- func (c *Context) DefaultQuery(key, defaultValue string) string
- func (c *Context) Error(err error) error
- func (c *Context) Errors() []error
- func (c *Context) File(filepath string)
- func (c *Context) Get(key string) (interface{}, bool)
- func (c *Context) GetHeader(key string) string
- func (c *Context) JSON(code int, obj interface{})
- func (c *Context) Next()
- func (c *Context) Param(key string) string
- func (c *Context) Query(key string) string
- func (c *Context) Redirect(code int, location string)
- func (c *Context) Request() *http.Request
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetHeader(key, value string)
- func (c *Context) SetStatus(code int)
- func (c *Context) ShouldBindJSON(obj interface{}) error
- func (c *Context) String(code int, format string, values ...interface{})
- func (c *Context) Writer() http.ResponseWriter
- type ErrorHandlerMiddleware
- type LoggingMiddleware
- type RouterGroup
- func (g *RouterGroup) DELETE(path string, handlers ...core.HandlerFunc)
- func (g *RouterGroup) GET(path string, handlers ...core.HandlerFunc)
- func (g *RouterGroup) Group(path string) core.RouterGroup
- func (g *RouterGroup) PATCH(path string, handlers ...core.HandlerFunc)
- func (g *RouterGroup) POST(path string, handlers ...core.HandlerFunc)
- func (g *RouterGroup) PUT(path string, handlers ...core.HandlerFunc)
- func (g *RouterGroup) RegisterRouter(controllers ...core.Controller)
- func (g *RouterGroup) Use(middleware ...core.HandlerFunc)
- type Server
- func (s *Server) DELETE(path string, handlers ...core.HandlerFunc)
- func (s *Server) GET(path string, handlers ...core.HandlerFunc)
- func (s *Server) GetErrorHandlerMiddleware() core.IErrorHandlerMiddleware
- func (s *Server) GetLoggingMiddleware() core.ILoggingMiddleware
- func (s *Server) GetPort() string
- func (s *Server) Group(path string) core.RouterGroup
- func (s *Server) NoMethod(handlers ...core.HandlerFunc)
- func (s *Server) NoRoute(handlers ...core.HandlerFunc)
- func (s *Server) PATCH(path string, handlers ...core.HandlerFunc)
- func (s *Server) POST(path string, handlers ...core.HandlerFunc)
- func (s *Server) PUT(path string, handlers ...core.HandlerFunc)
- func (s *Server) RegisterRouter(controllers ...core.Controller)
- func (s *Server) Run() error
- func (s *Server) RunTLS(addr, certFile, keyFile string) error
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) StartLambda() error
- func (s *Server) Stop() error
- func (s *Server) Use(middleware ...core.HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewErrorHandlerMiddleware ¶
func NewErrorHandlerMiddleware() middleware.IErrorHandlerMiddleware
NewErrorHandlerMiddleware creates a new ErrorHandlerMiddleware.
func NewLoggingMiddleware ¶
func NewLoggingMiddleware() core.ILoggingMiddleware
NewLoggingMiddleware creates a new LoggingMiddleware.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is an implementation of core.Context using the Gin framework.
func (*Context) Abort ¶ added in v0.0.6
func (c *Context) Abort()
Abort implements core.Context.Abort
func (*Context) DefaultQuery ¶
DefaultQuery implements core.Context.DefaultQuery
func (*Context) ShouldBindJSON ¶
ShouldBindJSON implements core.Context.ShouldBindJSON
func (*Context) Writer ¶
func (c *Context) Writer() http.ResponseWriter
Writer implements core.Context.Writer
type ErrorHandlerMiddleware ¶
type ErrorHandlerMiddleware struct {
// contains filtered or unexported fields
}
ErrorHandlerMiddleware is a Gin-specific implementation of middleware.IErrorHandlerMiddleware.
func (*ErrorHandlerMiddleware) Middleware ¶
func (m *ErrorHandlerMiddleware) Middleware(config *core.ErrorHandlerConfig) core.HandlerFunc
Middleware returns a middleware function that handles errors for Gin.
type LoggingMiddleware ¶
type LoggingMiddleware struct { middleware.BaseLoggingMiddleware // contains filtered or unexported fields }
LoggingMiddleware is a Gin-specific implementation of core.ILoggingMiddleware. It works with the Gin framework (github.com/gin-gonic/gin).
func (*LoggingMiddleware) Middleware ¶
func (m *LoggingMiddleware) Middleware(config *core.LoggingConfig) core.HandlerFunc
Middleware returns a middleware function that logs API requests for Gin. This implementation can capture the actual status code set by the handler.
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
RouterGroup is an implementation of core.RouterGroup using the Gin framework.
func (*RouterGroup) DELETE ¶
func (g *RouterGroup) DELETE(path string, handlers ...core.HandlerFunc)
DELETE implements core.RouterGroup.DELETE
func (*RouterGroup) GET ¶
func (g *RouterGroup) GET(path string, handlers ...core.HandlerFunc)
GET implements core.RouterGroup.GET
func (*RouterGroup) Group ¶
func (g *RouterGroup) Group(path string) core.RouterGroup
Group implements core.RouterGroup.Group
func (*RouterGroup) PATCH ¶
func (g *RouterGroup) PATCH(path string, handlers ...core.HandlerFunc)
PATCH implements core.RouterGroup.PATCH
func (*RouterGroup) POST ¶
func (g *RouterGroup) POST(path string, handlers ...core.HandlerFunc)
POST implements core.RouterGroup.POST
func (*RouterGroup) PUT ¶
func (g *RouterGroup) PUT(path string, handlers ...core.HandlerFunc)
PUT implements core.RouterGroup.PUT
func (*RouterGroup) RegisterRouter ¶
func (g *RouterGroup) RegisterRouter(controllers ...core.Controller)
RegisterRouter implements core.RouterGroup.RegisterRouter
func (*RouterGroup) Use ¶
func (g *RouterGroup) Use(middleware ...core.HandlerFunc)
Use implements core.RouterGroup.Use
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an implementation of core.Server using the Gin framework.
func NewServer ¶
NewServer creates a new Server instance using the Gin framework. If showLogs is true, logs about the framework, middleware, and routes will be printed to the console. If showLogs is false, these logs will be suppressed.
func (*Server) DELETE ¶
func (s *Server) DELETE(path string, handlers ...core.HandlerFunc)
DELETE implements core.Server.DELETE
func (*Server) GET ¶
func (s *Server) GET(path string, handlers ...core.HandlerFunc)
GET implements core.Server.GET
func (*Server) GetErrorHandlerMiddleware ¶
func (s *Server) GetErrorHandlerMiddleware() core.IErrorHandlerMiddleware
GetErrorHandlerMiddleware returns a Gin-specific error handler middleware.
func (*Server) GetLoggingMiddleware ¶
func (s *Server) GetLoggingMiddleware() core.ILoggingMiddleware
GetLoggingMiddleware returns a Gin-specific logging middleware.
func (*Server) Group ¶
func (s *Server) Group(path string) core.RouterGroup
Group implements core.Server.Group
func (*Server) NoMethod ¶
func (s *Server) NoMethod(handlers ...core.HandlerFunc)
NoMethod implements core.Server.NoMethod
func (*Server) NoRoute ¶
func (s *Server) NoRoute(handlers ...core.HandlerFunc)
NoRoute implements core.Server.NoRoute
func (*Server) PATCH ¶
func (s *Server) PATCH(path string, handlers ...core.HandlerFunc)
PATCH implements core.Server.PATCH
func (*Server) POST ¶
func (s *Server) POST(path string, handlers ...core.HandlerFunc)
POST implements core.Server.POST
func (*Server) PUT ¶
func (s *Server) PUT(path string, handlers ...core.HandlerFunc)
PUT implements core.Server.PUT
func (*Server) RegisterRouter ¶
func (s *Server) RegisterRouter(controllers ...core.Controller)
RegisterRouter implements core.Server.RegisterRouter
func (*Server) StartLambda ¶
StartLambda starts the server in AWS Lambda mode. This method should be called instead of Run or RunTLS when running in AWS Lambda. This method uses the ginadapter library to convert the Gin engine to a Lambda handler.
Example usage:
import ( "github.com/mythofleader/go-http-server" ) func main() { s, _ := server.NewServer(server.FrameworkGin, "8080") // ... configure your server ... if err := s.StartLambda(); err != nil { // Handle error } }
func (*Server) Use ¶
func (s *Server) Use(middleware ...core.HandlerFunc)
Use implements core.Server.Use