Documentation
¶
Index ¶
- Constants
- func Respond(w http.ResponseWriter, r *http.Request, resp Response)
- func RespondWithStatusCode(w http.ResponseWriter, r *http.Request, resp Response, status int)
- type Response
- func Error(message string) Response
- func ErrorWithData(message string, data map[string]any) Response
- func Forbidden(message string) Response
- func ForbiddenWithData(message string, data map[string]any) Response
- func Success(message string) Response
- func SuccessWithData(message string, data map[string]any) Response
- func Unauthenticated(message string) Response
- func UnauthenticatedWithData(message string, data map[string]any) Response
- func Unauthorized(message string) Response
- func UnauthorizedWithData(message string, data map[string]any) Response
Constants ¶
const TYPE_ERROR = "error"
const TYPE_FORBIDDEN = "forbidden"
const TYPE_SUCCESS = "success"
const TYPE_UNAUTHENTICATED = "unauthenticated"
const TYPE_UNAUTHORIZED = "unauthorized"
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 RespondWithStatusCode ¶ added in v1.6.0
Respond writes a JSON or JSONP response with a status code
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 ForbiddenWithData ¶ added in v1.6.0
ForbiddenWithData returns a forbidden message with data
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 (not authenticated)
func UnauthenticatedWithData ¶ added in v1.6.0
Unauthenticated returns an unauthenticated message, user is not known (not authenticated)
func Unauthorized ¶ added in v1.2.0
Unauthorized returns an unauthorized message, user is known but not unauthorized to do the action
func UnauthorizedWithData ¶ added in v1.6.0
Unauthorized returns an unauthorized message, user is known but not unauthorized to do the action