REST API: remove status from ApiResponse

it duplicates the header HTTP status
This commit is contained in:
Nicola Murino 2020-09-08 09:45:21 +02:00
parent b9c381e26f
commit 01850c7399
5 changed files with 180 additions and 875 deletions

View file

@ -15,9 +15,6 @@ jobs:
os: [ubuntu-latest, macos-latest]
upload-coverage: [true]
include:
- go: 1.13
os: ubuntu-latest
upload-coverage: false
- go: 1.14
os: ubuntu-latest
upload-coverage: false
@ -80,10 +77,13 @@ jobs:
if: startsWith(matrix.os, 'windows-') != true
run: |
mkdir -p output/{bash_completion,zsh_completion}
mkdir -p output/examples/rest-api-cli
cp sftpgo output/
cp sftpgo.json output/
cp -r templates output/
cp -r static output/
cp -r init output/
cp examples/rest-api-cli/sftpgo_api_cli.py output/examples/rest-api-cli/
./sftpgo gen completion bash > output/bash_completion/sftpgo-completion.bash
./sftpgo gen completion zsh > output/zsh_completion/_sftpgo
./sftpgo gen man -d output/man/man1

View file

@ -39,7 +39,7 @@ sudo systemctl enable sftpgo
# optional, install the REST API CLI. It requires python-requests to run
sudo install -Dm755 examples/rest-api-cli/sftpgo_api_cli.py /usr/bin/sftpgo_api_cli
# optional, create shell completion script, for example for bash
sudo /usr/bin/sftpgo gen completion bash > /etc/bash_completion.d/sftpgo-completion.bash
sudo sh -c '/usr/bin/sftpgo gen completion bash > /etc/bash_completion.d/sftpgo-completion.bash'
# optional, create man pages
sudo /usr/bin/sftpgo gen man -d /usr/share/man/man1
```

View file

@ -67,9 +67,8 @@ func sendAPIResponse(w http.ResponseWriter, r *http.Request, err error, message
errorString = err.Error()
}
resp := apiResponse{
Error: errorString,
Message: message,
HTTPStatus: code,
Error: errorString,
Message: message,
}
ctx := context.WithValue(r.Context(), render.StatusCtxKey, code)
render.JSON(w, r.WithContext(ctx), resp)

View file

@ -82,9 +82,8 @@ type Conf struct {
}
type apiResponse struct {
Error string `json:"error"`
Message string `json:"message"`
HTTPStatus int `json:"status"`
Error string `json:"error,omitempty"`
Message string `json:"message"`
}
// Initialize configures and starts the HTTP server

File diff suppressed because it is too large Load diff