Skip to content

Commit

Permalink
fix header middleware and postman collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mstgnz committed Jun 15, 2024
1 parent 6208d23 commit f6d3676
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 241 deletions.
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ func apiAuthMiddleware(next http.Handler) http.Handler {

func headerMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Content-Type") != "application/json" {
checkMethod := r.Method == "POST" || r.Method == "PUT" || r.Method == "PATCH"
if checkMethod && r.Header.Get("Content-Type") != "application/json" {
_ = config.WriteJSON(w, http.StatusBadRequest, config.Response{Status: false, Message: "Invalid Content-Type"})
return
}
Expand Down
Loading

0 comments on commit f6d3676

Please sign in to comment.