Documentation ¶
Index ¶
- func BuildOkResponse() map[string]interface{}
- func BuildOkResponseWithData(dataName string, data interface{}) map[string]interface{}
- func BuildResponse(status string) map[string]interface{}
- func Send(statusCode int, w http.ResponseWriter, data interface{}) error
- func SendAccepted(w http.ResponseWriter, data map[string]interface{}) error
- func SendCreated(w http.ResponseWriter, data map[string]interface{}) error
- func SendError(w http.ResponseWriter, err string) error
- func SendForbidden(w http.ResponseWriter, err string) error
- func SendInternalServerError(w http.ResponseWriter, err string) error
- func SendNotFound(w http.ResponseWriter, err string) error
- func SendResponse(w http.ResponseWriter, data map[string]interface{}) error
- func SendUnauthorized(w http.ResponseWriter, data map[string]interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildOkResponse ¶
func BuildOkResponse() map[string]interface{}
BuildOkResponse builds simple "ok" response
func BuildOkResponseWithData ¶
BuildOkResponseWithData builds response with status "ok" and data
func BuildResponse ¶
BuildResponse builds response for RestAPI request
func Send ¶
func Send(statusCode int, w http.ResponseWriter, data interface{}) error
Send sends HTTP response with a provided statusCode data can be either string or map[string]interface{} if data is string it will send response like this: {"status": data} which is helpful for explaining error to the client
Returned error value is based on error returned from json.Encoder
func SendAccepted ¶
func SendAccepted(w http.ResponseWriter, data map[string]interface{}) error
SendAccepted returns response with status Accepted 202
func SendCreated ¶
func SendCreated(w http.ResponseWriter, data map[string]interface{}) error
SendCreated returns response with status Created 201
func SendError ¶
func SendError(w http.ResponseWriter, err string) error
SendError returns error response with status Bad Request 400
func SendForbidden ¶
func SendForbidden(w http.ResponseWriter, err string) error
SendForbidden returns response with status Forbidden 403
func SendInternalServerError ¶
func SendInternalServerError(w http.ResponseWriter, err string) error
SendInternalServerError returns response with status Internal Server Error 500
func SendNotFound ¶
func SendNotFound(w http.ResponseWriter, err string) error
SendNotFound returns response with status Not Found 404
func SendResponse ¶
func SendResponse(w http.ResponseWriter, data map[string]interface{}) error
SendResponse returns JSON response with status OK 200
func SendUnauthorized ¶
func SendUnauthorized(w http.ResponseWriter, data map[string]interface{}) error
SendUnauthorized returns error response for unauthorized access with status Unauthorized 401
Types ¶
This section is empty.