diff --git a/httpListener.go b/httpListener.go index fd548b0..1d54bd8 100644 --- a/httpListener.go +++ b/httpListener.go @@ -13,7 +13,25 @@ type Data struct { Password string } -func handleRequest(w http.ResponseWriter, r *http.Request) { +type DataLogin struct { + Identifier string + Password string +} + +func handleRequestRoot(w http.ResponseWriter, r *http.Request) { + body, err := ioutil.ReadAll(r.Body) + if err != nil { + fmt.Printf("body read KO") + } + var data Data + err = json.Unmarshal(body, &data) + if err != nil { + fmt.Printf("deserialis KO") + } + fmt.Printf("%+v\n", data) +} + +func handleRequestLogin(w http.ResponseWriter, r *http.Request) { body, err := ioutil.ReadAll(r.Body) if err != nil { fmt.Printf("body read KO") @@ -28,6 +46,11 @@ func handleRequest(w http.ResponseWriter, r *http.Request) { func main() { mainORM() - http.HandleFunc("/", handleRequest) + http.HandleFunc("/", handleRequestRoot) + http.HandleFunc("/login", handleRequestLogin) + //http.HandleFunc("/", handleRequestRoot) + //http.HandleFunc("/", handleRequestRoot) + //http.HandleFunc("/", handleRequestRoot) + //http.HandleFunc("/", handleRequestRoot) log.Fatal(http.ListenAndServe(":8088", nil)) }