Documentation ¶
Index ¶
- func AddCustomType(name, pattern string) error
- func BindForm(r *http.Request, v interface{}) error
- func BindJSON(r *http.Request, v interface{}) error
- func BindXML(r *http.Request, v interface{}) error
- func CSRFMiddleware(next http.Handler) http.Handler
- func CachingMiddleware(duration time.Duration, next http.Handler) http.Handler
- func ContentNegotiationMiddleware(next http.Handler) http.Handler
- func LoggingMiddleware(next http.Handler) http.Handler
- func Param(r *http.Request, name string) string
- func RateLimitMiddleware(next http.Handler) http.Handler
- func RegisterParamType(name, pattern string)
- func RequestIDMiddleware(next http.Handler) http.Handler
- func Respond(w http.ResponseWriter, r *http.Request, status int, data interface{})
- func SetCSRFToken(w http.ResponseWriter)
- func UploadFile(r *http.Request, formKey, uploadDir string) (string, error)
- func ValidateStruct(s interface{}) error
- type CORSOptions
- type Middleware
- type MiddlewareChain
- type Route
- type RouteGroup
- type Router
- func (r *Router) DELETE(path string, handler http.HandlerFunc)
- func (r *Router) GET(path string, handler http.HandlerFunc)
- func (r *Router) Group(version string) *RouteGroup
- func (r *Router) Handle(method, path string, handler http.HandlerFunc, middleware ...Middleware)
- func (r *Router) POST(path string, handler http.HandlerFunc)
- func (r *Router) PUT(path string, handler http.HandlerFunc)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Use(middleware ...Middleware)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCustomType ¶
func CachingMiddleware ¶
func RegisterParamType ¶ added in v0.1.6
func RegisterParamType(name, pattern string)
RegisterParamType allows the registration of custom parameter types with specific regex patterns
func Respond ¶
func Respond(w http.ResponseWriter, r *http.Request, status int, data interface{})
Respond handles content negotiation and responds in the appropriate format
func SetCSRFToken ¶
func SetCSRFToken(w http.ResponseWriter)
Function to generate and set CSRF token cookie
func ValidateStruct ¶
func ValidateStruct(s interface{}) error
Types ¶
type CORSOptions ¶
type Middleware ¶
func CORS ¶
func CORS(opts CORSOptions) Middleware
type MiddlewareChain ¶
type MiddlewareChain []Middleware
type RouteGroup ¶
type RouteGroup struct {
// contains filtered or unexported fields
}
func (*RouteGroup) Handle ¶
func (g *RouteGroup) Handle(method, path string, handler http.HandlerFunc, middleware ...Middleware)
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Group ¶
func (r *Router) Group(version string) *RouteGroup
func (*Router) Handle ¶
func (r *Router) Handle(method, path string, handler http.HandlerFunc, middleware ...Middleware)
Handle adds a new route to the router
func (*Router) ServeHTTP ¶
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP makes the router implement the http.Handler interface Modified ServeHTTP function to apply middleware
func (*Router) Use ¶
func (r *Router) Use(middleware ...Middleware)
Use adds new middleware to the router
Click to show internal directories.
Click to hide internal directories.