Documentation ¶
Index ¶
- Variables
- func AccessLogMiddleware(next http.Handler) http.Handler
- func ErrorHandlerMiddleware(next http.Handler) http.Handler
- func HandleBadRequest(err error)
- func HandleHttpError(err error)
- func HandleHttpErrorWithStatusCode(stateCode int, err error, message string)
- func HandleMethodNotAllow(r *http.Request)
- func HandleNoPermission(err error, message string)
- func HandleNotFound(err error, message string)
- func HandleServerError(err error)
- func HandleUnauthorized(err error, message string)
- func RegisterCRUDApi(route *Route, pathPrefix string, api CRUDApi)
- func ResponseJson(response interface{}, statusCode int, w http.ResponseWriter)
- func RestControllerHandler(handle RestFunc) http.Handler
- type ApiStatus
- type CRUDApi
- type HttpError
- type MethodRoute
- func (route *MethodRoute) DELETE(handler http.Handler) *MethodRoute
- func (route *MethodRoute) GET(handler http.Handler) *MethodRoute
- func (route *MethodRoute) Handle(method string, handler http.Handler)
- func (route *MethodRoute) HandleFunc(method string, handler func(w http.ResponseWriter, r *http.Request))
- func (route *MethodRoute) POST(handler http.Handler) *MethodRoute
- func (route *MethodRoute) PUT(handler http.Handler) *MethodRoute
- func (route *MethodRoute) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type QueryParam
- func (q *QueryParam) Get(key string) string
- func (q *QueryParam) GetBool(key string) (bool, error)
- func (q *QueryParam) GetByte(key string) (byte, error)
- func (q *QueryParam) GetFloat(key string) (float64, error)
- func (q *QueryParam) GetInt(key string) (int64, error)
- func (q *QueryParam) GetString(key string) (string, error)
- func (q *QueryParam) GetTime(key string) (*time.Time, error)
- type QueryParamError
- type RestError
- type RestFunc
- type RestMethodRoute
- func (route *RestMethodRoute) DELETE(f RestFunc) *RestMethodRoute
- func (route *RestMethodRoute) GET(f RestFunc) *RestMethodRoute
- func (route *RestMethodRoute) Handle(method string, f RestFunc)
- func (route *RestMethodRoute) POST(f RestFunc) *RestMethodRoute
- func (route *RestMethodRoute) PUT(f RestFunc) *RestMethodRoute
- func (route *RestMethodRoute) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type RestResponse
- type Route
- func (route *Route) Handle(pattern string, handler http.Handler)
- func (route *Route) HandleFunc(pattern string, handler func(w http.ResponseWriter, r *http.Request))
- func (route *Route) MethodRoute(pattern string) *MethodRoute
- func (route *Route) RestMethodRoute(pattern string) *RestMethodRoute
- func (route *Route) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (route *Route) SubRoute(pattern string) *Route
Constants ¶
This section is empty.
Variables ¶
View Source
var ParamNotFoundError = errors.New("param not found")
View Source
var UnknownError = NewApiStatus("system", "0")
Functions ¶
func HandleBadRequest ¶
func HandleBadRequest(err error)
func HandleHttpError ¶
func HandleHttpError(err error)
func HandleMethodNotAllow ¶
func HandleNoPermission ¶
func HandleNotFound ¶
func HandleServerError ¶
func HandleServerError(err error)
func HandleUnauthorized ¶
func RegisterCRUDApi ¶
func ResponseJson ¶
func ResponseJson(response interface{}, statusCode int, w http.ResponseWriter)
func RestControllerHandler ¶
Types ¶
type ApiStatus ¶
type ApiStatus struct {
// contains filtered or unexported fields
}
func NewApiStatus ¶
type MethodRoute ¶
func (*MethodRoute) DELETE ¶
func (route *MethodRoute) DELETE(handler http.Handler) *MethodRoute
func (*MethodRoute) GET ¶
func (route *MethodRoute) GET(handler http.Handler) *MethodRoute
func (*MethodRoute) HandleFunc ¶
func (route *MethodRoute) HandleFunc(method string, handler func(w http.ResponseWriter, r *http.Request))
func (*MethodRoute) POST ¶
func (route *MethodRoute) POST(handler http.Handler) *MethodRoute
func (*MethodRoute) PUT ¶
func (route *MethodRoute) PUT(handler http.Handler) *MethodRoute
func (*MethodRoute) ServeHTTP ¶
func (route *MethodRoute) ServeHTTP(w http.ResponseWriter, r *http.Request)
type QueryParam ¶
func (*QueryParam) Get ¶
func (q *QueryParam) Get(key string) string
type QueryParamError ¶
type QueryParamError struct {
// contains filtered or unexported fields
}
func (*QueryParamError) Error ¶
func (q *QueryParamError) Error() string
func (*QueryParamError) Unwrap ¶
func (q *QueryParamError) Unwrap() error
type RestMethodRoute ¶
type RestMethodRoute struct {
// contains filtered or unexported fields
}
func (*RestMethodRoute) DELETE ¶
func (route *RestMethodRoute) DELETE(f RestFunc) *RestMethodRoute
func (*RestMethodRoute) GET ¶
func (route *RestMethodRoute) GET(f RestFunc) *RestMethodRoute
func (*RestMethodRoute) Handle ¶
func (route *RestMethodRoute) Handle(method string, f RestFunc)
func (*RestMethodRoute) POST ¶
func (route *RestMethodRoute) POST(f RestFunc) *RestMethodRoute
func (*RestMethodRoute) PUT ¶
func (route *RestMethodRoute) PUT(f RestFunc) *RestMethodRoute
func (*RestMethodRoute) ServeHTTP ¶
func (route *RestMethodRoute) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RestResponse ¶
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
func (*Route) HandleFunc ¶
func (*Route) MethodRoute ¶
func (route *Route) MethodRoute(pattern string) *MethodRoute
func (*Route) RestMethodRoute ¶
func (route *Route) RestMethodRoute(pattern string) *RestMethodRoute
Source Files ¶
Click to show internal directories.
Click to hide internal directories.