extractTenant extracts tenant ID from request context and returns HTTP error response if extraction fails
(req *http.Request, logger log.Logger)
| 13 | |
| 14 | // extractTenant extracts tenant ID from request context and returns HTTP error response if extraction fails |
| 15 | func extractTenant(req *http.Request, logger log.Logger) (string, *http.Response) { |
| 16 | tenant, err := user.ExtractOrgID(req.Context()) |
| 17 | if err != nil { |
| 18 | level.Error(logger).Log("msg", "failed to extract tenant id", "err", err) |
| 19 | return "", &http.Response{ |
| 20 | StatusCode: http.StatusBadRequest, |
| 21 | Status: http.StatusText(http.StatusBadRequest), |
| 22 | Body: io.NopCloser(strings.NewReader(err.Error())), |
| 23 | } |
| 24 | } |
| 25 | return tenant, nil |
| 26 | } |
| 27 | |
| 28 | func acceptAllBlocks(_ *backend.BlockMeta) bool { return true } |