Documentation ¶
Index ¶
- func BodyLimiterMiddleware(maxBodySize int64) func(handler http.Handler) http.Handler
- func FileServerMiddleware(prefix, dir string) func(next http.Handler) http.Handler
- func LoggerMiddleware(next http.Handler) http.Handler
- func RecovererMiddleware(next http.Handler) http.Handler
- func RequestIDMiddleware(next http.Handler) http.Handler
- func TimeoutMiddleware(timeout time.Duration) func(next http.Handler) http.Handler
- func WriteError(w http.ResponseWriter, s int, message string)
- func WriteErrorf(w http.ResponseWriter, status int, format string, args ...interface{})
- func WriteInternalError(ctx context.Context, w http.ResponseWriter, message string)
- func WriteInternalErrorf(ctx context.Context, w http.ResponseWriter, format string, args ...interface{})
- func WriteOK(w http.ResponseWriter, status int, v interface{})
- func WriteVerifyError(ctx context.Context, w http.ResponseWriter, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BodyLimiterMiddleware ¶
BodyLimiterMiddleware returns middleware which limits size of data read from request's body.
func FileServerMiddleware ¶
FileServerMiddleware serves requests with prefix into directory.
func LoggerMiddleware ¶
LoggerMiddleware puts logger with client's info into context.
func RecovererMiddleware ¶
RecovererMiddleware handles panics.
func RequestIDMiddleware ¶
RequestIDMiddleware puts request-id to headers and adds it into a logger.
func TimeoutMiddleware ¶
TimeoutMiddleware puts timeout context into request.
func WriteError ¶
func WriteError(w http.ResponseWriter, s int, message string)
WriteError writes error.
func WriteErrorf ¶
func WriteErrorf(w http.ResponseWriter, status int, format string, args ...interface{})
WriteErrorf writes formatted error.
func WriteInternalError ¶
func WriteInternalError(ctx context.Context, w http.ResponseWriter, message string)
WriteInternalError logs error and writes internal error.
func WriteInternalErrorf ¶ added in v0.0.2
func WriteInternalErrorf(ctx context.Context, w http.ResponseWriter, format string, args ...interface{})
WriteInternalErrorf logs formatted error and writes internal error.
func WriteOK ¶
func WriteOK(w http.ResponseWriter, status int, v interface{})
WriteOK writes json body.
func WriteVerifyError ¶
func WriteVerifyError(ctx context.Context, w http.ResponseWriter, err error)
WriteVerifyError writes proper error into w. Possible status codes: 400, 401, 500
Types ¶
This section is empty.