Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpolden/echoip.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'http/http.go')
-rw-r--r--http/http.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/http/http.go b/http/http.go
index 64260de..d7ed8a0 100644
--- a/http/http.go
+++ b/http/http.go
@@ -383,14 +383,15 @@ func wrapHandlerFunc(f http.HandlerFunc) appHandler {
func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if e := fn(w, r); e != nil { // e is *appError
- // When Content-Type for error is JSON, we need to marshal the response into JSON
if e.Code/100 == 5 {
log.Println(e.Error)
}
+ // When Content-Type for error is JSON, we need to marshal the response into JSON
if e.IsJSON() {
var data = struct {
+ Code int `json:"status"`
Error string `json:"error"`
- }{e.Message}
+ }{e.Code, e.Message}
b, err := json.MarshalIndent(data, "", " ")
if err != nil {
panic(err)