Documentation
¶
Index ¶
- Variables
- type CorsMiddleware
- type Error
- type HandlerFunc
- type Middleware
- type Reply
- type Request
- type ResponseWriter
- type Route
- type Router
- func (r *Router) Add(rts ...*Route) *Router
- func (r *Router) Delete(endpoint string, fn interface{}) *Route
- func (r *Router) Get(endpoint string, fn interface{}) *Route
- func (r *Router) Handler() *mux.Router
- func (r *Router) Patch(endpoint string, fn interface{}) *Route
- func (r *Router) Post(endpoint string, fn interface{}) *Route
- func (r *Router) Put(endpoint string, fn interface{}) *Route
- func (r *Router) ServeHTTP(hw http.ResponseWriter, hr *http.Request)
- func (r *Router) SetCustomReply(rpl Reply)
- func (r *Router) SetMethodNotAllowedHandlerFunc(handler func(ResponseWriter, *Request))
- func (r *Router) SetNotFoundHandlerFunc(handler func(ResponseWriter, *Request))
- func (r *Router) Use(middlewares ...Middleware) *Router
- func (r *Router) UseFunc(middlewareFuncs ...func(HandlerFunc) HandlerFunc) *Router
- type Vars
- func (vars Vars) Int(key string, defaultValue ...int) int
- func (vars Vars) Int32(key string, defaultValue ...int32) int32
- func (vars Vars) Int32Ok(key string) (ret int32, ok bool)
- func (vars Vars) Int64(key string, defaultValue ...int64) int64
- func (vars Vars) Int64Ok(key string) (ret int64, ok bool)
- func (vars Vars) IntOk(key string) (ret int, ok bool)
- func (vars Vars) Set(key string, value interface{})
- func (v Vars) String(key string, defaultValue ...string) string
- func (v Vars) StringOk(key string) (string, bool)
- func (vars Vars) Uint(key string, defaultValue ...uint) uint
- func (vars Vars) Uint32(key string, defaultValue ...uint32) uint32
- func (vars Vars) Uint32Ok(key string) (ret uint32, ok bool)
- func (vars Vars) Uint64(key string, defaultValue ...uint64) uint64
- func (vars Vars) Uint64Ok(key string) (ret uint64, ok bool)
- func (vars Vars) UintOk(key string) (ret uint, ok bool)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFoundEndpoint is error ErrNotFoundEndpoint = NewError(404, "endpoint_not_found", "Endpoint not found") )
Functions ¶
This section is empty.
Types ¶
type CorsMiddleware ¶
func (*CorsMiddleware) Middleware ¶
func (mw *CorsMiddleware) Middleware(next HandlerFunc) HandlerFunc
type Error ¶
func FromAnotherError ¶
FromAnotherError wrap any error to Error
func NewBadRequestError ¶
NewBadRequestError return error with BadRequest status
Using:
NewBadRequestError()
or
NewBadRequestError(message)
or
NewBadRequestError(code, message)
func NewInternalError ¶ added in v0.0.8
NewInternalError return error with BadRequest status
Using:
NewInternalError()
or
NewInternalError(message)
or
NewInternalError(code, message)
func NewNotFoundError ¶
NewNotFoundError return error with BadRequest status
Using:
NewNotFoundError()
or
NewNotFoundError(message)
or
NewNotFoundError(code, message)
type HandlerFunc ¶
type HandlerFunc func(ResponseWriter, *Request)
type Middleware ¶
type Middleware interface {
Middleware(next HandlerFunc) HandlerFunc
}
type ResponseWriter ¶
type ResponseWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
ResponseWriter implement rest ResponseWriter from http
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter, commonReply Reply) ResponseWriter
NewResponseWriter create new ResponseWriter instance
func (*ResponseWriter) WriteError ¶
func (w *ResponseWriter) WriteError(err error) bool
func (*ResponseWriter) WriteJSON ¶
func (w *ResponseWriter) WriteJSON(src interface{}) error
WriteJSON write src to response with encoding json
func (*ResponseWriter) WriteReply ¶
func (w *ResponseWriter) WriteReply(rpl Reply) (int, error)
func (*ResponseWriter) WriteResponse ¶
func (w *ResponseWriter) WriteResponse(resp interface{}) (int, error)
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is main router in rest
func (*Router) SetCustomReply ¶
func (*Router) SetMethodNotAllowedHandlerFunc ¶
func (r *Router) SetMethodNotAllowedHandlerFunc(handler func(ResponseWriter, *Request))
SetMethodNotAllowedHandlerFunc set not found handler
func (*Router) SetNotFoundHandlerFunc ¶
func (r *Router) SetNotFoundHandlerFunc(handler func(ResponseWriter, *Request))
SetNotFoundHandlerFunc set not found handler
func (*Router) Use ¶
func (r *Router) Use(middlewares ...Middleware) *Router
func (*Router) UseFunc ¶ added in v0.0.9
func (r *Router) UseFunc(middlewareFuncs ...func(HandlerFunc) HandlerFunc) *Router
type Vars ¶
type Vars map[string]interface{}
Vars is endpoint path variables
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
cors
command
|
|
|
custom-reply
command
|
|
|
logger
command
|
|
|
simple
command
|
Click to show internal directories.
Click to hide internal directories.
