Compojure uses the compojure.response/render protocol method to turn values
like URLs into Ring responses. So you could write:
(-> (io/resource "public/html/confirm.html")
(compojure.response/render)
(response/header "X-Foo" "Bar"))
Or you could use some middleware, if the header is standard across your
application. Or since you know that you're delivering a HTML file, you
could also write:
(-> (response/resource-response "public/html/confirm.html")
(response/content-type "text/html; charset=utf-8")
(response/header "X-Foo" "Bar"))
That should result in the same thing, as the only thing Compojure does that
Ring doesn't is try to make an educated guess about the content type.
- James
On 26 May 2015 at 13:22, Jonathon McKitrick <[email protected]> wrote:
> I have a GET route returning the result of this:
>
> (io/resource "public/html/confirm.html")
>
> but I need to add Cache-Control headers. Since the `resource` function
> returns a java.net.URL object, how can I add headers? The normal Ring way
> with ring.util.response/header only operates on a Ring response.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.