changeset 17:8ef859976bae

Fix bug in request routing
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 08 Oct 2016 13:16:33 +0200
parents 2cb083f1e2c4
children 350ccab814ca
files http/server.go
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/http/server.go	Sat Oct 08 13:16:15 2016 +0200
+++ b/http/server.go	Sat Oct 08 13:16:33 2016 +0200
@@ -54,17 +54,17 @@
 		return ""
 	}
 
-	if strings.HasSuffix(base, method_PREPARE) {
+	if strings.HasSuffix(path, method_PREPARE) {
 		return method_PREPARE
-	} else if strings.HasSuffix(base, method_ACCEPT) {
+	} else if strings.HasSuffix(path, method_ACCEPT) {
 		return method_ACCEPT
-	} else if strings.HasSuffix(base, method_ADDMEMBER) {
+	} else if strings.HasSuffix(path, method_ADDMEMBER) {
 		return method_ADDMEMBER
-	} else if strings.HasSuffix(base, method_RMMEMBER) {
+	} else if strings.HasSuffix(path, method_RMMEMBER) {
 		return method_RMMEMBER
-	} else if strings.HasSuffix(base, method_START_PARTICIPATION) {
+	} else if strings.HasSuffix(path, method_START_PARTICIPATION) {
 		return method_START_PARTICIPATION
-	} else if strings.HasSuffix(base, method_SUBMIT) {
+	} else if strings.HasSuffix(path, method_SUBMIT) {
 		return method_SUBMIT
 	} else {
 		return ""
@@ -74,7 +74,7 @@
 func (h ParticipantHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	if r.Method != "POST" {
 		w.WriteHeader(400)
-		w.Write(nil)
+		w.Write([]byte{})
 		return
 	}
 	defer r.Body.Close()
@@ -83,7 +83,7 @@
 
 	if method == "" {
 		w.WriteHeader(400)
-		w.Write(nil)
+		w.Write([]byte{})
 	}
 
 	switch method {
@@ -125,7 +125,7 @@
 	j, err := json.Marshal(FromError(e))
 
 	if err != nil {
-		w.Write(nil)
+		w.Write([]byte{})
 	} else {
 		w.Write(j)
 	}
@@ -136,7 +136,7 @@
 
 	if err != nil {
 		w.WriteHeader(500)
-		w.Write(nil)
+		w.Write([]byte{})
 	} else {
 		w.WriteHeader(200)
 		w.Write(j)