Documentation ¶
Index ¶
- func AccessMiddlewareFactory(secret string) func(http.Handler) http.Handler
- func BoolParameterFromURLInRequest(r *http.Request, name string) *bool
- func FloatParameterFromURLInRequest(r *http.Request, name string) *float64
- func GetBody(req *http.Request) (map[string]interface{}, error)
- func GetParameterFromURLInRequest(r *http.Request, key string) *string
- func Int64ParameterFromURLInRequest(r *http.Request, name string) *int64
- func IntParameterFromURLInRequest(r *http.Request, name string) *int
- func LoggingMiddleware(next http.Handler) http.Handler
- func RecoverMiddleware(next http.Handler) http.Handler
- func SetInContext(value interface{}, key interface{}, req *http.Request) *http.Request
- func WriteErr(w http.ResponseWriter, err error)
- func WriteJson(w http.ResponseWriter, value interface{}, code int)
- func WriteJsonOrError(w http.ResponseWriter, value interface{}, code int, err error)
- type DefaultRouter
- func (self *DefaultRouter) Delete(path string, handler http.Handler)
- func (self *DefaultRouter) Get(path string, handler http.Handler)
- func (self *DefaultRouter) Patch(path string, handler http.Handler)
- func (self *DefaultRouter) Post(path string, handler http.Handler)
- func (self *DefaultRouter) Put(path string, handler http.Handler)
- func (self *DefaultRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)
- type Error
- type Errors
- type IDContainer
- type Middleware
- type Parameters
- type Router
- type ServerError
- func DefaultHTTP403() *ServerError
- func HTTP400(description string) *ServerError
- func HTTP400Empty() *ServerError
- func HTTP401() *ServerError
- func HTTP403(code string) *ServerError
- func HTTP404(id string) *ServerError
- func HTTP500(err interface{}) *ServerError
- func NewServerError(statusCode int, code string, description string, key string, args []string) *ServerError
- func SafeConvertToServerError(err error) *ServerError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessMiddlewareFactory ¶
func SetInContext ¶
func WriteErr ¶
func WriteErr(w http.ResponseWriter, err error)
func WriteJson ¶
func WriteJson(w http.ResponseWriter, value interface{}, code int)
func WriteJsonOrError ¶
func WriteJsonOrError(w http.ResponseWriter, value interface{}, code int, err error)
Types ¶
type DefaultRouter ¶
type DefaultRouter struct {
DefaultRouter *httprouter.Router
}
func NewDefaultRouter ¶
func NewDefaultRouter() *DefaultRouter
func (*DefaultRouter) Patch ¶ added in v0.0.3
func (self *DefaultRouter) Patch(path string, handler http.Handler)
func (*DefaultRouter) ServeHTTP ¶
func (self *DefaultRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)
type Error ¶
type Error struct { Key string `json:"key, omitempty"` Description string `json:"description, omitempty"` Code string `json:"code"` Args []string `json:"args, omitempty"` }
func (Error) AsServerError ¶
func (Error) WriteWithCode ¶
func (err Error) WriteWithCode(code int, w http.ResponseWriter)
type IDContainer ¶
type IDContainer struct {
ID string `json:"id"`
}
func NewIDContainer ¶
func NewIDContainer(id string) *IDContainer
type Parameters ¶
type Parameters = map[string]interface{}
type ServerError ¶
func DefaultHTTP403 ¶
func DefaultHTTP403() *ServerError
func HTTP400 ¶
func HTTP400(description string) *ServerError
func HTTP400Empty ¶
func HTTP400Empty() *ServerError
func HTTP401 ¶
func HTTP401() *ServerError
func HTTP403 ¶
func HTTP403(code string) *ServerError
func HTTP404 ¶
func HTTP404(id string) *ServerError
func HTTP500 ¶
func HTTP500(err interface{}) *ServerError
func NewServerError ¶
func SafeConvertToServerError ¶
func SafeConvertToServerError(err error) *ServerError
func (ServerError) Error ¶
func (err ServerError) Error() string
func (ServerError) Write ¶
func (err ServerError) Write(w http.ResponseWriter)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.