Просмотр исходного кода

envelop body is used for debug purpose only.

master
sp 4 лет назад
Родитель
Сommit
612421221d
1 измененных файлов: 6 добавлений и 3 удалений
  1. +6
    -3
      apiV1Response.go

+ 6
- 3
apiV1Response.go Просмотреть файл

@@ -1,7 +1,7 @@
package main

import (
"biukop/sfm/loan"
"biukop.com/sfm/loan"
"encoding/json"
"fmt"
"net/http"
@@ -13,7 +13,7 @@ type apiV1Envelop struct {
Success bool
Msg string
TimeStamp string
Body interface{}
Body map[string]interface{}
Session loan.Session
}

@@ -30,6 +30,7 @@ func apiV1EnvelopBlank() (ret apiV1Envelop) {
Msg: "",
TimeStamp: ts,
}
ret.Body = make(map[string]interface{})
return
}

@@ -54,7 +55,9 @@ func (m *apiV1Response) toJson() (ret []byte, e error) {
func (m *apiV1Response) sendJson(w http.ResponseWriter) (ret []byte, e error) {
tempMap := m.tmp
m.tmp = nil
tempMap["_"] = m.Env
if config.Debug {
tempMap["_"] = m.Env
}
ret, e = json.Marshal(tempMap)
//sent
w.Header().Set("Content-Type", "text/json; charset=utf-8")

Загрузка…
Отмена
Сохранить