From 67d5cb61b348daeae7eeb582a74c52c1b49d0223 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Mon, 5 Jan 2015 15:58:30 -0800 Subject: [PATCH] Return 201, not 200, after creation of user --- handler.go | 1 + handler_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/handler.go b/handler.go index bc1aae4911..35e7a24b6b 100644 --- a/handler.go +++ b/handler.go @@ -276,6 +276,7 @@ func (h *Handler) serveCreateUser(w http.ResponseWriter, r *http.Request) { h.error(w, err.Error(), http.StatusInternalServerError) return } + w.WriteHeader(http.StatusCreated) } // serveUpdateUser updates an existing user. diff --git a/handler_test.go b/handler_test.go index 3b9e00885d..fcaee9f43e 100644 --- a/handler_test.go +++ b/handler_test.go @@ -421,7 +421,7 @@ func TestHandler_CreateUser(t *testing.T) { defer s.Close() status, body := MustHTTP("POST", s.URL+`/users`, `{"name":"jdoe","password":"1337"}`) - if status != http.StatusOK { + if status != http.StatusCreated { t.Fatalf("unexpected status: %d", status) } else if body != "" { t.Fatalf("unexpected body: %s", body)