Skip to content

Commit

Permalink
Correct structure of :headers for :options
Browse files Browse the repository at this point in the history
Was returning sequence of maps instead of just a map. Test needed
updating to reflect that and also that Ring's default middleware adds
headers.
  • Loading branch information
seancorfield committed Oct 20, 2016
1 parent d5f8957 commit b8f2327
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/framework/one.clj
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,12 @@
methods "OPTIONS,GET,POST,PUT,PATCH,DELETE"] ; should be dynamic, also include HEAD?
{:status 200
:body ""
:headers [{"Content-Type" "text/plain; charset=utf-8"}
{"Access-Control-Allow-Origin" (:origin access-control)}
{"Access-Control-Allow-Methods" methods}
{"Access-Control-Allow-Headers" (:headers access-control)}
{"Access-Control-Allow-Credentials" (:credentials access-control)}
{"Access-Control-Max-Age" (str (:max-age access-control))}]}))
:headers {"Content-Type" "text/plain; charset=utf-8"
"Access-Control-Allow-Origin" (:origin access-control)
"Access-Control-Allow-Methods" methods
"Access-Control-Allow-Headers" (:headers access-control)
"Access-Control-Allow-Credentials" (:credentials access-control)
"Access-Control-Max-Age" (str (:max-age access-control))}}))

(defn- default-middleware
"The default Ring middleware we apply in FW/1. Returns a single
Expand Down
12 changes: 6 additions & 6 deletions test/basic/expectations/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
(defn- header-name?
[name]
(fn [header]
(str/starts-with? (ffirst header) name)))
(str/starts-with? (first header) name)))

(expect (more-of {:keys [status headers body]}
200 status
"" body
6 (count headers)
5 (count (filter (header-name? "Access-Control") headers))
4 (count (filter (header-name? "Access-Control-Allow") headers)))
200 status
"" body
(partial <= 6) (count headers)
5 (count (filter (header-name? "Access-Control") headers))
4 (count (filter (header-name? "Access-Control-Allow") headers)))
(((fw1/configure-router {})) {:uri "/" :request-method :options}))

0 comments on commit b8f2327

Please sign in to comment.