Documentation
¶
Index ¶
- Variables
- func DefaultErrorHandler(c *Context, err error)
- type Config
- type Context
- func (ctx *Context) BadRequest(message string) error
- func (ctx *Context) BindJSON(v interface{}) error
- func (ctx *Context) Body() ([]byte, error)
- func (ctx *Context) Context() context.Context
- func (ctx *Context) Forbidden(message string) error
- func (ctx *Context) Get(key string) string
- func (ctx *Context) GetLocal(key string) (any, bool)
- func (ctx *Context) HTML(code int, html string) error
- func (ctx *Context) InternalServerError(message string) error
- func (ctx *Context) JSON(code int, data interface{}) error
- func (ctx *Context) Locals(key string) any
- func (ctx *Context) NotFound(message string) error
- func (ctx *Context) Param(key string) string
- func (ctx *Context) ParamInt(key string) (int, error)
- func (ctx *Context) PostForm(key string) string
- func (ctx *Context) Query(key string) string
- func (ctx *Context) QueryBool(key string) bool
- func (ctx *Context) QueryInt(key string, defaultValue ...int) int
- func (ctx *Context) Redirect(code int, location string) error
- func (ctx *Context) Set(key, value string)
- func (ctx *Context) SetContext(c context.Context)
- func (ctx *Context) SetLocal(key string, value any)
- func (ctx *Context) Status(code int) *Context
- func (ctx *Context) String(code int, format string, values ...interface{}) error
- func (ctx *Context) Unauthorized(message string) error
- type Error
- type ErrorHandler
- type HandlerFunc
- type MiddlewareFunc
- type Route
- type RouteGroup
- func (g *RouteGroup) DELETE(pattern string, handler HandlerFunc) *Route
- func (g *RouteGroup) GET(pattern string, handler HandlerFunc) *Route
- func (g *RouteGroup) Group(prefix string) *RouteGroup
- func (g *RouteGroup) Middleware(middleware ...MiddlewareFunc) *RouteGroup
- func (g *RouteGroup) PATCH(pattern string, handler HandlerFunc) *Route
- func (g *RouteGroup) POST(pattern string, handler HandlerFunc) *Route
- func (g *RouteGroup) PUT(pattern string, handler HandlerFunc) *Route
- type Router
- func (r *Router) DELETE(pattern string, handler HandlerFunc) *Route
- func (r *Router) GET(pattern string, handler HandlerFunc) *Route
- func (r *Router) HEAD(pattern string, handler HandlerFunc) *Route
- func (r *Router) Middleware(middleware ...MiddlewareFunc)
- func (r *Router) OPTIONS(pattern string, handler HandlerFunc) *Route
- func (r *Router) PATCH(pattern string, handler HandlerFunc) *Route
- func (r *Router) POST(pattern string, handler HandlerFunc) *Route
- func (r *Router) PUT(pattern string, handler HandlerFunc) *Route
- func (r *Router) Prefix(prefix string) *RouteGroup
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) URL(name string, params map[string]string) (string, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBadRequest = NewError(400) ErrForbidden = NewError(403) ErrNotFound = NewError(404) ErrMethodNotAllowed = NewError(405) ErrInternalServerError = NewError(500) ErrBadGateway = NewError(502) )
Predefined errors
Functions ¶
func DefaultErrorHandler ¶
DefaultErrorHandler handles errors with JSON response
Types ¶
type Config ¶
type Config struct {
ErrorHandler ErrorHandler
}
type Context ¶
type Context struct {
Request *http.Request
Writer http.ResponseWriter
Params map[string]string
// Trace IDs (extracted from headers, not auto-generated)
TraceID string
RequestID string
// Error tracking (generated on error)
ErrorID string
// contains filtered or unexported fields
}
func (*Context) BadRequest ¶
Error response helpers
func (*Context) InternalServerError ¶
func (*Context) SetContext ¶
func (*Context) Unauthorized ¶
type ErrorHandler ¶
type HandlerFunc ¶
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
func (*Route) Middleware ¶
func (route *Route) Middleware(middleware ...MiddlewareFunc) *Route
type RouteGroup ¶
type RouteGroup struct {
// contains filtered or unexported fields
}
func (*RouteGroup) DELETE ¶
func (g *RouteGroup) DELETE(pattern string, handler HandlerFunc) *Route
func (*RouteGroup) GET ¶
func (g *RouteGroup) GET(pattern string, handler HandlerFunc) *Route
func (*RouteGroup) Group ¶
func (g *RouteGroup) Group(prefix string) *RouteGroup
func (*RouteGroup) Middleware ¶
func (g *RouteGroup) Middleware(middleware ...MiddlewareFunc) *RouteGroup
func (*RouteGroup) PATCH ¶
func (g *RouteGroup) PATCH(pattern string, handler HandlerFunc) *Route
func (*RouteGroup) POST ¶
func (g *RouteGroup) POST(pattern string, handler HandlerFunc) *Route
func (*RouteGroup) PUT ¶
func (g *RouteGroup) PUT(pattern string, handler HandlerFunc) *Route
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Middleware ¶
func (r *Router) Middleware(middleware ...MiddlewareFunc)
func (*Router) Prefix ¶
func (r *Router) Prefix(prefix string) *RouteGroup
Click to show internal directories.
Click to hide internal directories.