Documentation ¶
Index ¶
- func HandleSQLError(err error) error
- func Recoverer(w http.ResponseWriter, r *http.Request) (context.Context, error)
- func SendJSON(w http.ResponseWriter, status int, obj interface{}) error
- type HTTPError
- func BadRequestError(fmtString string, args ...interface{}) *HTTPError
- func InternalServerError(fmtString string, args ...interface{}) *HTTPError
- func NotFoundError(fmtString string, args ...interface{}) *HTTPError
- func UnauthorizedError(fmtString string, args ...interface{}) *HTTPError
- func UnavailableServiceError(fmtString string, args ...interface{}) *HTTPError
- type Router
- func (r *Router) Delete(pattern string, fn apiHandler)
- func (r *Router) Get(pattern string, fn apiHandler)
- func (r *Router) Post(pattern string, fn apiHandler)
- func (r *Router) Put(pattern string, fn apiHandler)
- func (r *Router) Route(pattern string, fn func(*Router))
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Use(fn middlewareHandler)
- func (r *Router) UseBypass(fn func(next http.Handler) http.Handler)
- func (r *Router) With(fn middlewareHandler) *Router
- func (r *Router) WithBypass(fn func(next http.Handler) http.Handler) *Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleSQLError ¶
Types ¶
type HTTPError ¶
type HTTPError struct { Object string `json:"object"` Code int `json:"code"` Message string `json:"msg"` Json interface{} `json:"json"` InternalError error `json:"-"` InternalMessage string `json:"-"` ErrorID string `json:"error_id,omitempty"` }
HTTPError is an error with a message and an HTTP status code.
func BadRequestError ¶
====================================== Return bad request error ======================================
func InternalServerError ¶
====================================== Return internal server error ======================================
func NotFoundError ¶
====================================== Return not found error ======================================
func UnauthorizedError ¶
====================================== Return unauthorized error ======================================
func UnavailableServiceError ¶
====================================== Return unavailable service error ======================================
func (*HTTPError) Cause ¶
====================================== Cause returns the root cause error ======================================
func (*HTTPError) Error ¶
====================================== Return error as string ======================================
func (*HTTPError) WithInternalError ¶
====================================== WithInternalError adds internal error information to the error ======================================
func (*HTTPError) WithInternalMessage ¶
====================================== WithInternalMessage adds internal message information to the error ======================================
func (*HTTPError) WithJsonError ¶
====================================== WithJsonError ======================================
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
====================================== Router wrapper ======================================
func NewRouter ¶
func NewRouter() *Router
====================================== Create new Router ======================================
func (*Router) Route ¶
====================================== Default methods ======================================
func (*Router) ServeHTTP ¶
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
====================================== Serve ======================================