-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return an Error on Incorrect Content-Type for Search Requests
Closes: #524
- Loading branch information
1 parent
49bcdf5
commit 575588a
Showing
7 changed files
with
122 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
modules/rest-api/src/blaze/rest_api/middleware/ensure_form_body.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(ns blaze.rest-api.middleware.ensure-form-body | ||
(:require | ||
[blaze.anomaly :as ba] | ||
[blaze.async.comp :as ac] | ||
[ring.util.request :as request])) | ||
|
||
|
||
(defn wrap-ensure-form-body [handler] | ||
(fn [request] | ||
(if (request/urlencoded-form? request) | ||
(handler request) | ||
(ac/completed-future | ||
(ba/incorrect | ||
(if (request/content-type request) | ||
"Unsupported Content-Type header `application/fhir+json`. Please use `application/x-www-form-urlencoded`." | ||
"Missing Content-Type header. Please use `application/x-www-form-urlencoded`.") | ||
:http/status 415))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters