func (s *SchemaHTTPService) writeJsonReponse(w http.ResponseWriter, r *http.Request, data interface{}, code int) { w.Header().Set("Access-Control-Allow-Origin", ACL_ALLOW_ORIGIN) //w.Header().Set("Access-Control-Allow-Headers", ACL_ALLOW_HEADERS) wrappers.WriteHttpJsonResponse(w, r, data, code) //s.logger.Info.Printf("%d %s\n", code, r.URL.RequestURI()) s.logger.Info.Printf("%s %d %s\n", r.Method, code, r.URL.RequestURI()) }
func (c *ConfigService) configHandler(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": var tmp = map[string]interface{}{ "endpoints": c.epConfig, } b, err := ioutil.ReadFile(c.ConfigFile) if err != nil { w.WriteHeader(500) w.Write([]byte(err.Error())) return } err = json.Unmarshal(b, &tmp) if err != nil { w.WriteHeader(500) w.Write([]byte(err.Error())) return } wrappers.WriteHttpJsonResponse(w, r, tmp, 200) break default: w.WriteHeader(405) break } }