rest

package
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 14 Imported by: 20

Documentation

Index

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

func GetUserInfo(r *http.Request) (user store.User, err error)

GetUserInfo returns user from request context

func GetUserOrEmpty added in v1.4.0

func GetUserOrEmpty(r *http.Request) store.User

GetUserOrEmpty attempts to get user info from request and returns empty object if failed

func MustGetUserInfo

func MustGetUserInfo(r *http.Request) store.User

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

func SetUserInfo

func SetUserInfo(r *http.Request, user store.User) *http.Request

SetUserInfo sets user into request context

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL