Documentation ¶
Index ¶
- func ErrAccessDenied(err error) render.Renderer
- func ErrInvalidRequest(err error) render.Renderer
- func ErrNotFound(err error) render.Renderer
- func ErrUnathorized(err error) render.Renderer
- func NewContactsResponse(contact *ent.Contact) render.Renderer
- func NewContactsResponseList(contactList []*ent.Contact) []render.Renderer
- type ContactPayload
- type ContactResponsePayload
- type ErrResponse
- type TokenPayloadResponse
- type User
- type UserPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrAccessDenied ¶
func ErrInvalidRequest ¶
func ErrNotFound ¶
func ErrUnathorized ¶
Types ¶
type ContactPayload ¶
type ContactResponsePayload ¶
type ContactResponsePayload struct { ID int `json:"id"` Name string `json:"name"` Phone string `json:"phone"` Address string `json:"address"` }
func (*ContactResponsePayload) Render ¶
func (c *ContactResponsePayload) 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 TokenPayloadResponse ¶
type TokenPayloadResponse struct {
Token string `json:"token"`
}
func (*TokenPayloadResponse) Render ¶
func (t *TokenPayloadResponse) Render(w http.ResponseWriter, r *http.Request) error
type UserPayload ¶
func NewUserPayloadResponse ¶
func NewUserPayloadResponse(user *ent.User) *UserPayload
func (*UserPayload) Render ¶
func (u *UserPayload) Render(w http.ResponseWriter, r *http.Request) error
Click to show internal directories.
Click to hide internal directories.