mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-11-29 22:08:10 +02:00
update deps and simplify some code
This commit is contained in:
@@ -2,6 +2,7 @@ package httpd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -53,11 +54,8 @@ func sendAPIResponse(w http.ResponseWriter, r *http.Request, err error, message
|
||||
Message: message,
|
||||
HTTPStatus: code,
|
||||
}
|
||||
if code != http.StatusOK {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(code)
|
||||
}
|
||||
render.JSON(w, r, resp)
|
||||
ctx := context.WithValue(r.Context(), render.StatusCtxKey, code)
|
||||
render.JSON(w, r.WithContext(ctx), resp)
|
||||
}
|
||||
|
||||
func getRespStatus(err error) int {
|
||||
|
||||
Reference in New Issue
Block a user