mirror of
https://github.com/kaaninchen/Laterna.git
synced 2026-09-17 19:12:48 +00:00
feat: add http status code to responses
This commit is contained in:
@@ -17,6 +17,7 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HTTPResponse struct {
|
type HTTPResponse struct {
|
||||||
|
Status int `json:"status"`
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
Error string `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
Timestamp string `json:"timestamp"`
|
Timestamp string `json:"timestamp"`
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ func WriteJSONResponse(w http.ResponseWriter, statusCode int, res models.HTTPRes
|
|||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(statusCode)
|
w.WriteHeader(statusCode)
|
||||||
|
|
||||||
|
res.Status = statusCode
|
||||||
res.Timestamp = time.Now().UTC().Format(time.RFC3339)
|
res.Timestamp = time.Now().UTC().Format(time.RFC3339)
|
||||||
|
|
||||||
json.NewEncoder(w).Encode(res)
|
json.NewEncoder(w).Encode(res)
|
||||||
|
|||||||
Reference in New Issue
Block a user