From ee21f00d3fb9ee1010e70c840cc516d2af23490e Mon Sep 17 00:00:00 2001 From: dylan Date: Tue, 31 Dec 2024 15:30:45 +0100 Subject: [PATCH] Set Location header after creating an election --- cmd/web/handlers.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index b9a7b38..94fd05e 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -4,6 +4,7 @@ import ( api "code.dlmw.ch/dlmw/qv/internal" "code.dlmw.ch/dlmw/qv/internal/validator" "encoding/json" + "fmt" "math/rand" "net/http" "time" @@ -59,6 +60,7 @@ func (app *application) createElection(w http.ResponseWriter, r *http.Request) { } } + w.Header().Set("Location", fmt.Sprintf("/elections/%v", electionId)) w.Write(res) }