Documentation
¶
Index ¶
- Constants
- func BackendCheck(log *zerolog.Logger, b backend.Backend) func(next http.Handler) http.Handler
- func GetChartID(ctx context.Context) string
- func GetCreateChartRequest(ctx context.Context) *render.CreateChartRequest
- func GetRequestID(ctx context.Context) string
- func MarshalJSON(w http.ResponseWriter, statusCode int, v interface{})
- func Recover(log *zerolog.Logger) func(next http.Handler) http.Handler
- func RequestObserver(log *zerolog.Logger, mrec metric.Recorder) func(next http.Handler) http.Handler
- func RequireChartID(log *zerolog.Logger) func(next http.Handler) http.Handler
- func RequireCreateChartParams(log *zerolog.Logger) func(next http.Handler) http.Handler
- func SetRequestID(log *zerolog.Logger) func(next http.Handler) http.Handler
Constants ¶
const ( // RequestIDLogKey represents a request ID key logger field. RequestIDLogKey = "request_id" // ChartIDLogKey represents a chart ID key logger field. ChartIDLogKey = "chart_id" )
Variables ¶
This section is empty.
Functions ¶
func BackendCheck ¶
BackendCheck checks if backend is healthy and returns http.StatusServiceUnavailable if it's not.
func GetChartID ¶
GetChartID retrieves chart_id value from context.
func GetCreateChartRequest ¶
GetCreateChartRequest retrieves create chart request from context.
func GetRequestID ¶
GetRequestID returns request ID or empty string if it's not set.
func MarshalJSON ¶
func MarshalJSON(w http.ResponseWriter, statusCode int, v interface{})
MarshalJSON marshals 'v' to JSON, automatically escaping HTML, setting the Content-Type as application/json and writing headers with the provided status code. It calls http.Error in case of failures.
func RequestObserver ¶
func RequestObserver(log *zerolog.Logger, mrec metric.Recorder) func(next http.Handler) http.Handler
RequestObserver handles observability (metrics and logging) for every request.
func RequireChartID ¶
RequireChartID checks that chart_id parameter can be used and stores it in the context.
func RequireCreateChartParams ¶
RequireCreateChartParams checks if provided create chart parameters body can be used and stores it in the context.
Types ¶
This section is empty.