mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
fix(http): downgrade canOnboard check to warning log level (#1859)
This commit is contained in:
parent
ac1974c8d5
commit
99a9e6bc0f
2 changed files with 17 additions and 0 deletions
|
@ -156,6 +156,10 @@ func (h authHandler) onboard(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
func (h authHandler) canOnboard(w http.ResponseWriter, r *http.Request) {
|
func (h authHandler) canOnboard(w http.ResponseWriter, r *http.Request) {
|
||||||
if status, err := h.onboardEligible(r.Context()); err != nil {
|
if status, err := h.onboardEligible(r.Context()); err != nil {
|
||||||
|
if status == http.StatusServiceUnavailable {
|
||||||
|
h.encoder.StatusWarning(w, status, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
h.encoder.StatusError(w, status, err)
|
h.encoder.StatusError(w, status, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,3 +130,16 @@ func (e encoder) StatusError(w http.ResponseWriter, status int, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e encoder) StatusWarning(w http.ResponseWriter, status int, message string) {
|
||||||
|
resp := errorResponse{
|
||||||
|
Status: status,
|
||||||
|
Message: message,
|
||||||
|
}
|
||||||
|
|
||||||
|
e.log.Warn().Str("warning", message).Int("status", status).Msg("server warning")
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
w.WriteHeader(status)
|
||||||
|
json.NewEncoder(w).Encode(resp)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue