Hmm.  I tried this:

(-> (io/resource "public/html/confirm.html")
             (cr/render)
             (resp/header "Cache-Control" "no-cache, no-store"))

and got this:

Exception in thread "main" java.lang.IllegalArgumentException: No single 
method: render of interface: compojure.response.Renderable found for 
function: render of protocol: Renderable, compiling:(pts/server.clj:483:14)

On Tuesday, May 26, 2015 at 8:43:21 AM UTC-4, James Reeves wrote:
>
> 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] 
> <javascript:>> 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] 
>> <javascript:>
>> 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] <javascript:>
>> 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] <javascript:>.
>> 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.

Reply via email to