reitit
reitit copied to clipboard
Problem with header-parameters
Ring lowercases request headers, which means this doesn't work:
["/"
{:get {:parameters {:header {:Authorization s/Str}}
:handler (fn [request]
{:status 200
:body (get-in request [:parameters :header :Authorization])})}}]
I guess there are options:
- header-params are declared as String, e.g.
{:headers {"Authorization" string?}}
- as CamelCase keywords, the coercion reads them correctly
{:headers {:Authorization string?}}
- as lower-case keywords, camel-cased for api-docs
{:headers {:authorization string?}}
- something else
- Header params are declared as lower-case strings
{:headers {"authorization" string?}}
which would match exactly what Ring provides us. (Could still HTTP-Header-Case them for documentation.)
what if someone really want's to use a lowercase header like x-my-secret-token
? the doc generation would do it wrong.
HTTP headers are case-insensitive and a Ring-using application can't distinguish between x-my-secret-token
and X-My-Secret-Token
because Ring converts them to lower-case anyway, so I'd just not support that case.
Hey there. Does this work with swagger-ui? I'm trying to get an "Authorization" headers field to magically appear so that I can enter a JWT token string and test my API, but I can't figure out how to do it. I'm trying the below, and everything is working with curl... Just that swagger isn't showing any way to add auth header.
:get {:summary "list offers"
:parameters {:headers {"authorization" string?}}
... etc
- Header params are declared as lower-case strings
{:headers {"authorization" string?}}
which would match exactly what Ring provides us. (Could still HTTP-Header-Case them for documentation.)