Documentation ¶
Index ¶
- func Respond(w http.ResponseWriter, r *http.Request, resp Response)
- func RespondWithStatus(w http.ResponseWriter, r *http.Request, resp Response, status int)
- type Response
- func Error(message string) Response
- func ErrorWithData(message string, data map[string]interface{}) Response
- func Forbidden(message string) Response
- func Success(message string) Response
- func SuccessWithData(message string, data map[string]interface{}) Response
- func Unauthenticated(message string) Response
- func Unauthorized(message string) Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Respond ¶
func Respond(w http.ResponseWriter, r *http.Request, resp Response)
Respond writes a JSON or JSONP response
func RespondWithStatus ¶ added in v1.5.0
Respond writes a JSON or JSONP response
Types ¶
type Response ¶
type Response struct { Status string `json:"status"` Message string `json:"message"` Data map[string]interface{} `json:"data"` }
Response defines an response for the API
func ErrorWithData ¶
ErrorWithData returns an error message with data
func Forbidden ¶ added in v1.2.0
Forbidden returns an forbidden message, user is authenticated but insufficient permissions
func SuccessWithData ¶
SuccessWithData returns a success message with data
func Unauthenticated ¶ added in v1.4.0
Unauthenticated returns an unauthenticated message, user is not known (authenticated)
func Unauthorized ¶ added in v1.2.0
Unauthorized returns an unauthorized message, user is known but not unauthorized to do the action
Click to show internal directories.
Click to hide internal directories.