Documentation
¶
Index ¶
- type ApiError
- type Config
- type ErrorResponse
- type ErrorType
- type HTTPServer
- type HTTPServerOption
- type Handler
- type InternalError
- type Middleware
- func (m *Middleware) Apply(router *gin.Engine)
- func (m *Middleware) CORS() gin.HandlerFunc
- func (m *Middleware) Logger() gin.HandlerFunc
- func (m *Middleware) MaxBodySize(limit int64) gin.HandlerFunc
- func (m *Middleware) PrettyLog() gin.HandlerFunc
- func (m *Middleware) Profiling() gin.HandlerFunc
- func (m *Middleware) Recovery() gin.HandlerFunc
- type Response
- type ResponseWriter
- func (rw *ResponseWriter) BadRequest(c *gin.Context, msg string)
- func (rw *ResponseWriter) Created(c *gin.Context, data interface{})
- func (rw *ResponseWriter) Error(c *gin.Context, err error)
- func (rw *ResponseWriter) InternalServerError(c *gin.Context, err error)
- func (rw *ResponseWriter) NoContent(c *gin.Context)
- func (rw *ResponseWriter) NotFound(c *gin.Context)
- func (rw *ResponseWriter) Success(c *gin.Context, data interface{})
- func (rw *ResponseWriter) Unauthorized(c *gin.Context)
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiError ¶
type ApiError struct {
Code int `json:"code,omitempty"`
Message string `json:"message"`
TraceID string `json:"trace_id"`
}
func ToApiError ¶
ToApiError converts error to API-safe structure
type Config ¶
type Config struct {
Port string
Environment string
Version string
MaxRequestSize int64
EnableProfiling bool
ShutdownTimeout time.Duration
}
Config defines runtime configuration
func DefaultConfig ¶
func DefaultConfig() *Config
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer is the main implementation
func NewHTTPServer ¶
func NewHTTPServer(cfg *Config, opts ...HTTPServerOption) *HTTPServer
func (*HTTPServer) GetLogger ¶
func (s *HTTPServer) GetLogger() api.Logger
func (*HTTPServer) GetResponseWriter ¶
func (s *HTTPServer) GetResponseWriter() *ResponseWriter
func (*HTTPServer) Router ¶
func (s *HTTPServer) Router() *gin.Engine
func (*HTTPServer) Start ¶
func (s *HTTPServer) Start() error
type HTTPServerOption ¶
type HTTPServerOption func(*HTTPServer)
func WithHandler ¶
func WithHandler(handler Handler) HTTPServerOption
func WithLogger ¶
func WithLogger(logger api.Logger) HTTPServerOption
func WithMiddleware ¶
func WithMiddleware(m *Middleware) HTTPServerOption
func WithResponseWriter ¶
func WithResponseWriter(w *ResponseWriter) HTTPServerOption
func WithShutdownFunc ¶
func WithShutdownFunc(fn func()) HTTPServerOption
type InternalError ¶
InternalError wraps errors with context
func NewError ¶
func NewError(errType ErrorType, message string, err error) *InternalError
NewError creates a new structured internal error
func (*InternalError) Error ¶
func (e *InternalError) Error() string
func (*InternalError) ToHttpMessage ¶
func (e *InternalError) ToHttpMessage() string
func (*InternalError) ToHttpStatusCode ¶
func (e *InternalError) ToHttpStatusCode() int
func (*InternalError) Unwrap ¶
func (e *InternalError) Unwrap() error
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware(logger api.Logger, config *Config) *Middleware
func (*Middleware) Apply ¶
func (m *Middleware) Apply(router *gin.Engine)
func (*Middleware) CORS ¶
func (m *Middleware) CORS() gin.HandlerFunc
func (*Middleware) Logger ¶
func (m *Middleware) Logger() gin.HandlerFunc
func (*Middleware) MaxBodySize ¶
func (m *Middleware) MaxBodySize(limit int64) gin.HandlerFunc
func (*Middleware) PrettyLog ¶
func (m *Middleware) PrettyLog() gin.HandlerFunc
func (*Middleware) Profiling ¶
func (m *Middleware) Profiling() gin.HandlerFunc
func (*Middleware) Recovery ¶
func (m *Middleware) Recovery() gin.HandlerFunc
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
func NewResponseWriter ¶
func NewResponseWriter(logger api.Logger) *ResponseWriter
func (*ResponseWriter) BadRequest ¶
func (rw *ResponseWriter) BadRequest(c *gin.Context, msg string)
Shorthand helpers
func (*ResponseWriter) Created ¶
func (rw *ResponseWriter) Created(c *gin.Context, data interface{})
func (*ResponseWriter) InternalServerError ¶
func (rw *ResponseWriter) InternalServerError(c *gin.Context, err error)
func (*ResponseWriter) NoContent ¶
func (rw *ResponseWriter) NoContent(c *gin.Context)
func (*ResponseWriter) NotFound ¶
func (rw *ResponseWriter) NotFound(c *gin.Context)
func (*ResponseWriter) Success ¶
func (rw *ResponseWriter) Success(c *gin.Context, data interface{})
func (*ResponseWriter) Unauthorized ¶
func (rw *ResponseWriter) Unauthorized(c *gin.Context)
Click to show internal directories.
Click to hide internal directories.