Documentation ¶
Index ¶
- Constants
- Variables
- func Context(ctx context.Context) context.Context
- func NewContext() context.Context
- type Error
- type Herodot
- type JSON
- func (h *JSON) Write(ctx context.Context, w http.ResponseWriter, r *http.Request, e interface{})
- func (h *JSON) WriteCode(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, ...)
- func (h *JSON) WriteCreated(ctx context.Context, w http.ResponseWriter, r *http.Request, location string, ...)
- func (h *JSON) WriteError(ctx context.Context, w http.ResponseWriter, r *http.Request, err error)
- func (h *JSON) WriteErrorCode(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, ...)
Constants ¶
View Source
const RequestIDKey key = 0
Variables ¶
View Source
var ( ErrNotFound = &Error{ Err: errors.New("Not found"), Code: http.StatusNotFound, } Err: errors.New("Unauthorized"), Code: http.StatusUnauthorized, } ErrBadRequest = &Error{ Err: errors.New("Bad request"), Code: http.StatusBadRequest, } ErrForbidden = &Error{ Err: errors.New("Forbidden"), Code: http.StatusForbidden, } )
Functions ¶
func NewContext ¶
Types ¶
type Herodot ¶
type Herodot interface { Write(ctx context.Context, w http.ResponseWriter, r *http.Request, e interface{}) WriteCode(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, e interface{}) WriteCreated(ctx context.Context, w http.ResponseWriter, r *http.Request, location string, e interface{}) WriteError(ctx context.Context, w http.ResponseWriter, r *http.Request, err error) WriteErrorCode(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, err error) }
type JSON ¶
type JSON struct {
Logger logrus.FieldLogger
}
func (*JSON) WriteCreated ¶
func (*JSON) WriteError ¶
Click to show internal directories.
Click to hide internal directories.