diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-16 22:57:30 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-16 22:57:30 +0100 |
commit | a11be80cf0c13263791f3e4f82fda461acd77130 (patch) | |
tree | f1a128255fd25d9bbe80c48d6019c36b2f83bf8c /appservice/server.go | |
parent | d2ccd6763a8a8a88e5cdbf95fd665e679f8e187e (diff) | |
download | easybridge-a11be80cf0c13263791f3e4f82fda461acd77130.tar.gz easybridge-a11be80cf0c13263791f3e4f82fda461acd77130.zip |
Work
Diffstat (limited to 'appservice/server.go')
-rw-r--r-- | appservice/server.go | 21 |
1 files changed, 13 insertions, 8 deletions
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) + } } |