Documentation ¶
Overview ¶
Package admin ties together administration resources and handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadRequest return status 400 Bad Request for malformed request body. ErrBadRequest = &ErrResponse{HTTPStatusCode: http.StatusBadRequest, StatusText: http.StatusText(http.StatusBadRequest)} // ErrNotFound returns status 404 Not Found for invalid resource request. ErrNotFound = &ErrResponse{HTTPStatusCode: http.StatusNotFound, StatusText: http.StatusText(http.StatusNotFound)} // ErrInternalServerError returns status 500 Internal Server Error. ErrInternalServerError = &ErrResponse{HTTPStatusCode: http.StatusInternalServerError, StatusText: http.StatusText(http.StatusInternalServerError)} )
var (
ErrAccountValidation = errors.New("account validation error")
)
The list of error types returned from account resource.
Functions ¶
func ErrInvalidRequest ¶
ErrInvalidRequest returns status 422 Unprocessable Entity including error message.
Types ¶
type API ¶
type API struct {
Accounts *AccountResource
}
API provides admin application resources and handlers.
type AccountResource ¶
type AccountResource struct {
Store AccountStore
}
AccountResource implements account management handler.
func NewAccountResource ¶
func NewAccountResource(store AccountStore) *AccountResource
NewAccountResource creates and returns an account resource.
type AccountStore ¶
type AccountStore interface { List(f auth.AccountFilter) ([]auth.Account, int, error) Create(*auth.Account) error Get(id int) (*auth.Account, error) Update(*auth.Account) error Delete(*auth.Account) error }
AccountStore defines database operations for account management.
type ErrResponse ¶
type ErrResponse struct { Err error `json:"-"` // low-level runtime error HTTPStatusCode int `json:"-"` // http response status code StatusText string `json:"status"` // user-level status message AppCode int64 `json:"code,omitempty"` // application-specific error code ErrorText string `json:"error,omitempty"` // application-level error message, for debugging }
ErrResponse renderer type for handling all sorts of errors.
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
Render sets the application-specific error code in AppCode.
type ErrValidationResponse ¶
type ErrValidationResponse struct { *ErrResponse Errors string `json:"errors,omitempty"` }
ErrValidationResponse renderer for handling validation errors.
func (*ErrValidationResponse) Render ¶
func (ev *ErrValidationResponse) Render(w http.ResponseWriter, r *http.Request) error
Render sets the application-specific error code in AppCode.