Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnhandled = Error{ Status: http.StatusInternalServerError, Code: "internal_server_error", Message: "Oops, sorry! There's an unhandled error in here somewhere.", } ErrNotFound = Error{ Status: http.StatusNotFound, Code: "not_found", Message: "The requested route does not exist.", } ErrMethodNotAllowed = Error{ Status: http.StatusMethodNotAllowed, Code: "method_not_allowed", Message: "The requested HTTP method cannot be handled by this route.", } ErrMissingAuthz = Error{ Status: http.StatusUnauthorized, Code: "missing_authorization", Message: "The Authorization header was missing or the wrong format.", } ErrInvalidAuthz = Error{ Status: http.StatusUnauthorized, Code: "invalid_authorization", Message: "The provided credentials were not valid.", } )
View Source
var ErrFromVar = errors.New("fromVar: unhandled type")
Functions ¶
func FromBody ¶
FromBody reads the request body and unmarshals the JSON into v. For types that implement Validator, this returns v.Validate() after unmarshaling.
func FromVars ¶
FromVars unpacks URL parameters into v. For types that implement Validator, this returns v.Validate() after unpacking.
This is intended to be called with the result of mux.Vars.
Unpacking is done with json.Marshal, with some overrides for specific types:
- If a type implements Param, its FromParam method will be used. - For string and []byte, the value will be returned as-is. - Complex numbers will use strconv.ParseComplex with the correct bit size.
func LogRequests ¶
func LogRequests(log *zap.Logger) mux.MiddlewareFunc
Types ¶
type Error ¶
type Error struct { Status httpStatus `json:"status"` Code ErrorCode `json:"code"` Message string `json:"message"` }
func NoResourceError ¶
func ValidationError ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Authenticate ¶
Click to show internal directories.
Click to hide internal directories.