1
0
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:
Nicola Murino
2020-01-31 23:26:56 +01:00
parent e647f3626e
commit 31a433cda2
6 changed files with 100 additions and 55 deletions

View File

@@ -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 {