Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSON ¶
func JSON(w http.ResponseWriter, l *zap.Logger, status int, v interface{})
JSON serializes the given struct as JSON into the response body. It also sets the Content-Type as "application/json" and X-Content-Type-Options as "nosniff". Logs the status and v if l is not nil.
func JSONError ¶
func JSONError(w http.ResponseWriter, l *zap.Logger, err error)
JSONError returns an HTTP response as JSON message with status code base on app err Kind, Msg from app err HTTPMessage. Logs the error if l is not nil.
func SetJSONErrorResponse ¶ added in v1.0.2
func SetJSONErrorResponse(fn func(err error) interface{})
SetJSONErrorResponse useful for handling errors differently, define custom response.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.