diff --git a/apiv1.go b/apiv1.go index 460cfb4..5e90e17 100644 --- a/apiv1.go +++ b/apiv1.go @@ -26,13 +26,13 @@ type apiV1Envelop struct { } type apiV1Response struct { - apiV1Envelop + Env apiV1Envelop Body interface{} } var apiV1Handler = []apiV1HandlerMap{ {"POST", "login", apiV1Login}, - {"GET", "login", dummyHandler}, + {"GET", "login", apiV1DumpRequest}, } //apiV1Main version 1 main entry for all REST API @@ -56,8 +56,7 @@ func apiV1Login(w http.ResponseWriter, r *http.Request) { p := loan.User{} p.FakeNew() - res := apiV1Response{} - res.apiV1Envelop = apiV1EnvelopBlank() + res := apiV1ResponseBlank() res.Body = p apiSendJson(res, w) @@ -79,7 +78,7 @@ func apiV1DumpRequest(w http.ResponseWriter, r *http.Request) { msg := fmt.Sprintf("Unhandled Protocol = %s path= %s", r.Method, r.URL.Path) dumpLines := strings.Split(dump, "\r\n") ar := apiV1ResponseBlank() - ar.Msg = msg + ar.Env.Msg = msg ar.Body = dumpLines b, _ := json.Marshal(ar) fmt.Fprintf(w, "%s\n", b) @@ -97,6 +96,6 @@ func apiV1EnvelopBlank() (ret apiV1Envelop) { } func apiV1ResponseBlank() (ret apiV1Response) { - ret.apiV1Envelop = apiV1EnvelopBlank() + ret.Env = apiV1EnvelopBlank() return } diff --git a/main.go b/main.go index a0e1def..53d353f 100644 --- a/main.go +++ b/main.go @@ -32,7 +32,7 @@ func main() { func setupRootFileServer() { //root of doc for idx, node := range config.Static { - log.Printf("setting up %d static with %+v\n", idx, node) + log.Printf("setting up static %d with %+v\n", idx, node) fs := http.FileServer(http.Dir(node.Dir)) http.Handle(node.StaticUrl, http.StripPrefix(node.StripPrefix, fs)) }