Documentation
¶
Index ¶
- Variables
- func AdaptMiddleware(w func(http.Handler) http.Handler) func(handle httprouter.Handle) httprouter.Handle
- func ExtractAndCall(target interface{}, w http.ResponseWriter, r *http.Request, ...)
- func ExtractAndCallWithBody(target interface{}, body interface{}, w http.ResponseWriter, r *http.Request, ...)
- func ExtractParameters(target interface{}, r *http.Request, params httprouter.Params) error
- func WriteBody(writer http.ResponseWriter, status int, contentType string, content []byte, ...) error
- func WriteError(writer http.ResponseWriter, status int, err error) error
- func WriteGenericError(w http.ResponseWriter, err error)
- func WriteJSON(w http.ResponseWriter, status int, value interface{}, headers ...Header) error
- func WriteResponseValue(w http.ResponseWriter, value interface{}, err error, headers ...Header)
- func WriteResponseValueStatus(w http.ResponseWriter, statusCode int, value interface{}, err error, ...)
- type ErrorResponse
- type Header
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorMapping = map[error]int{ sql.ErrNoRows: http.StatusNotFound, sql.ErrTxDone: http.StatusInternalServerError, }
Functions ¶
func AdaptMiddleware ¶
func AdaptMiddleware(w func(http.Handler) http.Handler) func(handle httprouter.Handle) httprouter.Handle
Wraps a normal http.Handler middleware and wraps it so it can be used with httprouter.Handle functions.
func ExtractAndCall ¶
func ExtractAndCall(target interface{}, w http.ResponseWriter, r *http.Request, params httprouter.Params, handler func() (interface{}, error))
func ExtractAndCallWithBody ¶ added in v1.2.8
func ExtractAndCallWithBody(
target interface{},
body interface{},
w http.ResponseWriter,
r *http.Request,
params httprouter.Params,
handler func() (interface{}, error))
func ExtractParameters ¶
func ExtractParameters(target interface{}, r *http.Request, params httprouter.Params) error
func WriteError ¶
func WriteError(writer http.ResponseWriter, status int, err error) error
func WriteGenericError ¶
func WriteGenericError(w http.ResponseWriter, err error)
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, status int, value interface{}, headers ...Header) error
func WriteResponseValue ¶
func WriteResponseValue(w http.ResponseWriter, value interface{}, err error, headers ...Header)
func WriteResponseValueStatus ¶
func WriteResponseValueStatus(w http.ResponseWriter, statusCode int, value interface{}, err error, headers ...Header)
Types ¶
type ErrorResponse ¶
Click to show internal directories.
Click to hide internal directories.