Documentation ¶
Index ¶
- Constants
- func Data(w http.ResponseWriter, statusCode int, contentType string, body []byte) error
- func DefaultLoggingFunc(w *logging.Writer, r *http.Request)
- func GetOrCreateTraceID(r *http.Request) string
- func GetTraceID(r *http.Request) string
- func HandlerAuthJWT(secret string) func(next Handler) Handler
- func JSON(w http.ResponseWriter, statusCode int, obj any) error
- func JWTDecode(secret, token string) ([]byte, error)
- func JWTEncode(secret, payload string) string
- func NoContent(w http.ResponseWriter) error
- func ParseRequest(r *http.Request, obj any) error
- func ReverseProxy(addr string) *httputil.ReverseProxy
- func Text(w http.ResponseWriter, statusCode int, msg string) error
- func UserID(r *http.Request) string
- func UserIP(r *http.Request) string
- type File
- type Group
- func (g Group) ANY(pattern string, handler Handler, middlewares ...Middleware)
- func (g Group) DELETE(pattern string, handler Handler, middlewares ...Middleware)
- func (g Group) GET(pattern string, handler Handler, middlewares ...Middleware)
- func (g Group) NewGroup(middlewares ...Middleware) Group
- func (g Group) PATCH(pattern string, handler Handler, middlewares ...Middleware)
- func (g Group) POST(pattern string, handler Handler, middlewares ...Middleware)
- func (g Group) PUT(pattern string, handler Handler, middlewares ...Middleware)
- type Handler
- type LoggingFunc
- type Middleware
- type ResponseError
- func BadGateway(err error) ResponseError
- func BadRequest(err error) ResponseError
- func Forbidden(err error) ResponseError
- func InternalServerError(err error) ResponseError
- func MethodNotAllowed() ResponseError
- func NewError(code int, err error) ResponseError
- func NotFound() ResponseError
- func Unauthorized(err error) ResponseError
- type Route
- type Router
- func (ro *Router) ANY(pattern string, h Handler, middlewares ...Middleware)
- func (ro *Router) Catch(next Handler) http.HandlerFunc
- func (ro *Router) DELETE(pattern string, h Handler, middlewares ...Middleware)
- func (ro *Router) GET(pattern string, h Handler, middlewares ...Middleware)
- func (ro *Router) NewGroup(middleware ...Middleware) Group
- func (ro *Router) PATCH(pattern string, h Handler, middlewares ...Middleware)
- func (ro *Router) POST(pattern string, h Handler, middlewares ...Middleware)
- func (ro *Router) PUT(pattern string, h Handler, middlewares ...Middleware)
- func (ro *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (ro *Router) Use(middlewares ...Middleware)
- func (ro *Router) UseLogging(loggingFunc LoggingFunc)
- type ServeMux
Constants ¶
View Source
const ( ContentTypeJSON = "application/json; charset=utf-8" ContentTypeHTML = "text/html; charset=utf-8" ContentTypeTEXT = "text/plain; charset=utf-8" )
View Source
const TraceIDHeader = "X-Trace-Id"
Variables ¶
This section is empty.
Functions ¶
func GetOrCreateTraceID ¶
func GetTraceID ¶
func HandlerAuthJWT ¶
func NoContent ¶
func NoContent(w http.ResponseWriter) error
func ReverseProxy ¶
func ReverseProxy(addr string) *httputil.ReverseProxy
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (Group) DELETE ¶
func (g Group) DELETE(pattern string, handler Handler, middlewares ...Middleware)
func (Group) NewGroup ¶
func (g Group) NewGroup(middlewares ...Middleware) Group
type Middleware ¶
type ResponseError ¶
type ResponseError struct { Code int `json:"code"` Message string `json:"message"` ContentType string `json:"content-type,omitempty"` Source string `json:"source,omitempty"` }
func BadGateway ¶
func BadGateway(err error) ResponseError
func BadRequest ¶
func BadRequest(err error) ResponseError
func Forbidden ¶
func Forbidden(err error) ResponseError
func InternalServerError ¶
func InternalServerError(err error) ResponseError
func MethodNotAllowed ¶
func MethodNotAllowed() ResponseError
func NewError ¶
func NewError(code int, err error) ResponseError
func NotFound ¶
func NotFound() ResponseError
func Unauthorized ¶
func Unauthorized(err error) ResponseError
func (ResponseError) Error ¶
func (e ResponseError) Error() string
func (ResponseError) ServeHTTP ¶
func (e ResponseError) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (ResponseError) WithJSON ¶
func (e ResponseError) WithJSON() ResponseError
func (ResponseError) WithSource ¶
func (e ResponseError) WithSource(source string) ResponseError
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) DELETE ¶
func (ro *Router) DELETE(pattern string, h Handler, middlewares ...Middleware)
func (*Router) NewGroup ¶
func (ro *Router) NewGroup(middleware ...Middleware) Group
func (*Router) PATCH ¶
func (ro *Router) PATCH(pattern string, h Handler, middlewares ...Middleware)
func (*Router) Use ¶
func (ro *Router) Use(middlewares ...Middleware)
func (*Router) UseLogging ¶
func (ro *Router) UseLogging(loggingFunc LoggingFunc)
type ServeMux ¶ added in v0.0.2
type ServeMux struct {
// contains filtered or unexported fields
}
func (*ServeMux) HandlerOn404 ¶ added in v0.0.2
func (mux *ServeMux) HandlerOn404(h http.HandlerFunc)
func (*ServeMux) HandlerOn405 ¶ added in v0.0.2
func (mux *ServeMux) HandlerOn405(h http.HandlerFunc)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.