From a11be80cf0c13263791f3e4f82fda461acd77130 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 16 Feb 2020 22:57:30 +0100 Subject: Work --- appservice/server.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'appservice/server.go') diff --git a/appservice/server.go b/appservice/server.go index 8e4c263..3f52119 100644 --- a/appservice/server.go +++ b/appservice/server.go @@ -62,13 +62,18 @@ func checkTokenAndLog(handler http.Handler) http.Handler { } func handleTxn(w http.ResponseWriter, r *http.Request) { - var txn mxlib.Transaction - err := json.NewDecoder(r.Body).Decode(&txn) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - } - - log.Printf("Got transaction %#v\n", txn) + if r.Method == "PUT" { + var txn mxlib.Transaction + err := json.NewDecoder(r.Body).Decode(&txn) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + log.Printf("JSON decode error: %s\n", err) + return + } - fmt.Fprintf(w, "{}\n") + log.Printf("Got transaction %#v\n", txn) + fmt.Fprintf(w, "{}\n") + } else { + http.Error(w, "Expected PUT request", http.StatusBadRequest) + } } -- cgit v1.2.3