我正在尝试在 Go Lang 上创建一个 RESTful API,返回 JSON 值。当我加载页面时,我没有在页面上获得任何价值。有人可以帮我在这里..?
type sessiond struct{
apiKey string `json:"apiKey"`
token string `json:"token"`
}
func dummy(w http.ResponseWriter, r *http.Request) {
se:=sessiond{apiKey:key,token:"erer"}
log.Println(se); // Iam getting the value here ! but nothing on the page.
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
if err := json.NewEncoder(w).Encode(se); err != nil {
panic(err)
}
//res.R200(w, se)
}
天涯尽头无女友
相关分类