ailistener-old

The central Server which transports webhook events from the Dialogflow bot to the local nodes
git clone git://archive.git.mtrnord.blog/OpenHomeAuto/ailistener-old.git
Log | Files | Refs | README | LICENSE

commit e3a2b59cc2191451e994a0f07e5210aa14a2d432
parent 2ea376d428226587b6f020a9f01766994640d891
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sat,  2 Jun 2018 10:49:55 +0200

Unmarshal params too

Diffstat:
MwsListener/server.go | 18+++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/wsListener/server.go b/wsListener/server.go @@ -22,6 +22,14 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) { } func DFHandler(w http.ResponseWriter, r *http.Request) { + type params struct { + Artist string `json:"music-artist"` + Room string `json:"room"` + Genre int `json:"MusikGenre"` + } + + var p params + var dfr *df.Request if r.Body == nil { @@ -32,8 +40,16 @@ func DFHandler(w http.ResponseWriter, r *http.Request) { decoder := json.NewDecoder(r.Body) if err := decoder.Decode(&dfr); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + // Retrieve the params of the request + if err := dfr.GetParams(&p); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return } - log.Printf("%+v", dfr.QueryResult) + log.Printf("REQUEST: %+v", dfr.QueryResult) + log.Printf("PARAMS: %+v", p) // Send back a fulfillment dff := &df.Fulfillment{