Documentation ¶
Index ¶
- func PromMetrics(serviceName string, buckets []float64) func(next http.Handler) http.Handler
- func RenderJSON(next http.Handler) http.Handler
- func ZapLogger(logger *zap.Logger) func(next http.Handler) http.Handler
- type Response
- func (r *Response) AddError(err string) *Response
- func (r *Response) AddHeader(key, value string) *Response
- func (r *Response) SetHeader(key, value string) *Response
- func (r *Response) SetPayload(payload interface{}) *Response
- func (r *Response) SetStatus(statusCode int) *Response
- func (r *Response) SetStatusAccepted() *Response
- func (r *Response) SetStatusBadRequest(err string) *Response
- func (r *Response) SetStatusForbidden(err string) *Response
- func (r *Response) SetStatusInternalServerError(err string) *Response
- func (r *Response) SetStatusNotFound(err string) *Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PromMetrics ¶
PromMetrics returns middleware with Prometheus metrics.
func RenderJSON ¶
RenderJSON middleware is used to inject response object in context and later render it as JSON.
Types ¶
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response ...
func ResponseFromContext ¶
ResponseFromContext returns response from context.
func (*Response) SetPayload ¶
SetPayload sets payload to response.
func (*Response) SetStatus ¶
SetStatus sets status code to response. If status code is not set if will default to http.StatusOK.
func (*Response) SetStatusAccepted ¶
SetStatusAccepted sets status code to http.StatusAccepted.
func (*Response) SetStatusBadRequest ¶
SetStatusBadRequest sets status code to http.StatusBadRequest.
func (*Response) SetStatusForbidden ¶
SetStatusForbidden sets status code to http.StatusForbidden.
func (*Response) SetStatusInternalServerError ¶
SetStatusInternalServerError sets status code to http.StatusInternalServerError.
func (*Response) SetStatusNotFound ¶
SetStatusNotFound sets status code to http.StatusNotFound.