| 420 | } |
| 421 | |
| 422 | func respondAccepted(w http.ResponseWriter, logger log.Logger) { |
| 423 | b, err := json.Marshal(&util_api.Response{ |
| 424 | Status: "success", |
| 425 | }) |
| 426 | if err != nil { |
| 427 | level.Error(logger).Log("msg", "error marshaling json response", "err", err) |
| 428 | util_api.RespondError(logger, w, v1.ErrServer, "unable to marshal the requested data", http.StatusInternalServerError) |
| 429 | return |
| 430 | } |
| 431 | w.Header().Set("Content-Type", "application/json") |
| 432 | |
| 433 | // Return a status accepted because the rule has been stored and queued for polling, but is not currently active |
| 434 | w.WriteHeader(http.StatusAccepted) |
| 435 | if n, err := w.Write(b); err != nil { |
| 436 | level.Error(logger).Log("msg", "error writing response", "bytesWritten", n, "err", err) |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | // parseNamespace parses the namespace from the provided set of params, in this |
| 441 | // api these params are derived from the url path |