Documentation ¶
Index ¶
- Constants
- func GetUserInfo(r *http.Request) (user store.User, err error)
- func GetUserOrEmpty(r *http.Request) store.User
- func MustGetUserInfo(r *http.Request) store.User
- func SendErrorHTML(w http.ResponseWriter, r *http.Request, httpStatusCode int, err error, ...)
- func SendErrorJSON(w http.ResponseWriter, r *http.Request, httpStatusCode int, err error, ...)
- func SetUserInfo(r *http.Request, user store.User) *http.Request
Constants ¶
View Source
const ( ErrInternal = 0 // any internal error ErrCommentNotFound = 1 // can't find comment ErrDecode = 2 // failed to unmarshal incoming request ErrNoAccess = 3 // rejected by auth ErrCommentValidation = 4 // validation failed ErrPostNotFound = 5 // can't find post ErrSiteNotFound = 6 // can't find site ErrUserBlocked = 7 // user blocked ErrReadOnly = 8 // write failed on read only ErrCommentRejected = 9 // general error on rejected comment change ErrCommentEditExpired = 10 // too late for edit ErrCommentEditChanged = 11 // parent comment cannot be changed ErrVoteRejected = 12 // general error on vote rejected ErrVoteSelf = 13 // vote for own comment ErrVoteDbl = 14 // already voted for the comment ErrVoteMax = 15 // too many votes for the comment ErrVoteMinScore = 16 // min score reached for the comment ErrActionRejected = 17 // general error for rejected actions ErrAssetNotFound = 18 // requested file not found )
All error codes for UI mapping and translation
Variables ¶
This section is empty.
Functions ¶
func GetUserInfo ¶
GetUserInfo returns user from request context
func GetUserOrEmpty ¶ added in v1.4.0
GetUserOrEmpty attempts to get user info from request and returns empty object if failed
func MustGetUserInfo ¶
MustGetUserInfo fails if can't extract user data from the request. should be called from authed controllers only
func SendErrorHTML ¶ added in v1.5.0
func SendErrorHTML(w http.ResponseWriter, r *http.Request, httpStatusCode int, err error, details string, errCode int)
SendErrorHTML makes html body with provided template and responds with provided http status code, error code is not included in render as it is intended for UI developers and not for the users
func SendErrorJSON ¶
func SendErrorJSON(w http.ResponseWriter, r *http.Request, httpStatusCode int, err error, details string, errCode int)
SendErrorJSON makes {error: blah, details: blah} json body and responds with error code
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.