Skip to content

Commit

Permalink
Allow only GET requests
Browse files Browse the repository at this point in the history
  • Loading branch information
th0th committed Dec 13, 2020
1 parent 7913a66 commit 3cf293b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down

0 comments on commit 3cf293b

Please sign in to comment.