Documentation
¶
Index ¶
- Variables
- func AuthenticatorSimpleSingleKey(key string) func(next http.Handler) http.Handler
- func ErrInternal(err error) render.Renderer
- func ErrInvalidRequest(err error) render.Renderer
- func ErrRender(err error) render.Renderer
- func NewListResponse[T render.Renderer](items []T) []render.Renderer
- type CategoryRequest
- type CategoryResponse
- type ErrResponse
- type FreezerItemRequest
- type FreezerItemResponse
- type ItemTypeRequest
- type ItemTypeResponse
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrForbidden = ErrNotFound
Servers may also send 404 Not found instead of 403 Forbidden to hide the existence of a resource from an unauthorized client.
View Source
var ErrInvalidID error = errors.New("Invalid Item ID")
View Source
var ErrItemNotFount error = errors.New("Item not found")
View Source
var ErrNotFound = &ErrResponse{ HTTPStatusCode: http.StatusNotFound, StatusText: "Resource not found.", }
Functions ¶
func ErrInternal ¶
func ErrInvalidRequest ¶
Types ¶
type CategoryRequest ¶
type CategoryResponse ¶
func (CategoryResponse) Render ¶
func (c CategoryResponse) Render(w http.ResponseWriter, r *http.Request) error
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.
In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
type FreezerItemRequest ¶
type FreezerItemRequest struct{ models.FreezerItem }
type FreezerItemResponse ¶
type FreezerItemResponse struct{ models.FreezerItem }
func (FreezerItemResponse) Render ¶
func (c FreezerItemResponse) Render(w http.ResponseWriter, r *http.Request) error
type ItemTypeRequest ¶
type ItemTypeResponse ¶
func (ItemTypeResponse) Render ¶
func (c ItemTypeResponse) Render(w http.ResponseWriter, r *http.Request) error
Click to show internal directories.
Click to hide internal directories.