mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add logs
This commit is contained in:
parent
5e3ee66bae
commit
7144b0d61d
1 changed files with 14 additions and 0 deletions
|
@ -28,9 +28,11 @@ func (app *application) showCommandHandler(w http.ResponseWriter, r *http.Reques
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Logger.Infow("GET Command",
|
app.Logger.Infow("GET Command",
|
||||||
"Command", command,
|
"Command", command,
|
||||||
)
|
)
|
||||||
|
|
||||||
err = app.writeJSON(w, http.StatusOK, envelope{"command": command}, nil)
|
err = app.writeJSON(w, http.StatusOK, envelope{"command": command}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.serverErrorResponse(w, r, err)
|
app.serverErrorResponse(w, r, err)
|
||||||
|
@ -67,6 +69,10 @@ func (app *application) createCommandHandler(w http.ResponseWriter, r *http.Requ
|
||||||
headers := make(http.Header)
|
headers := make(http.Header)
|
||||||
headers.Set("Location", fmt.Sprintf("/v1/commands/%s", command.Name))
|
headers.Set("Location", fmt.Sprintf("/v1/commands/%s", command.Name))
|
||||||
|
|
||||||
|
app.Logger.Infow("PUT Command",
|
||||||
|
"Command", command,
|
||||||
|
)
|
||||||
|
|
||||||
err = app.writeJSON(w, http.StatusCreated, envelope{"command": command}, headers)
|
err = app.writeJSON(w, http.StatusCreated, envelope{"command": command}, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.serverErrorResponse(w, r, err)
|
app.serverErrorResponse(w, r, err)
|
||||||
|
@ -131,6 +137,10 @@ func (app *application) updateCommandHandler(w http.ResponseWriter, r *http.Requ
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.Logger.Infow("PATCH Command",
|
||||||
|
"Command", command,
|
||||||
|
)
|
||||||
|
|
||||||
err = app.writeJSON(w, http.StatusOK, envelope{"command": command}, nil)
|
err = app.writeJSON(w, http.StatusOK, envelope{"command": command}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.serverErrorResponse(w, r, err)
|
app.serverErrorResponse(w, r, err)
|
||||||
|
@ -156,6 +166,10 @@ func (app *application) deleteCommandHandler(w http.ResponseWriter, r *http.Requ
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.Logger.Infow("DELETE Command",
|
||||||
|
"Name", name,
|
||||||
|
)
|
||||||
|
|
||||||
err = app.writeJSON(w, http.StatusOK, envelope{"message": fmt.Sprintf("command %s deleted", name)}, nil)
|
err = app.writeJSON(w, http.StatusOK, envelope{"message": fmt.Sprintf("command %s deleted", name)}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.serverErrorResponse(w, r, err)
|
app.serverErrorResponse(w, r, err)
|
||||||
|
|
Loading…
Reference in a new issue