From 3cf293bfd4f6613649749bea3832fffb880f707d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6khan=20Sar=C4=B1?= Date: Sun, 13 Dec 2020 21:09:10 +0300 Subject: [PATCH] Allow only GET requests --- http/server.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/http/server.go b/http/server.go index 4c6d57e..b67ac45 100644 --- a/http/server.go +++ b/http/server.go @@ -30,6 +30,17 @@ func NewServer(d domain) Server { } func (s *Server) index(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + errorResponse, _ := json.Marshal(ErrorResponse{ + Detail: "email query parameter should be set.", + }) + + w.WriteHeader(405) + w.Write(errorResponse) + + return + } + email := r.URL.Query().Get("email") if email == "" {