aboutsummaryrefslogtreecommitdiff
path: root/appservice/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'appservice/server.go')
-rw-r--r--appservice/server.go21
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)
+ }
}