Fork me on GitHub
#yada
<
2017-06-13
>
lmergen07:06:17

which of all the yada interceptors is the one that actually invokes the :response function ?

malcolmsparks07:06:19

yada.interceptors/invoke-method

malcolmsparks07:06:49

indirectly - the method proxies are called, and a method proxy will call the response function (depending on the semantics of the method)

malcolmsparks07:06:21

e.g. the HEAD method will not even call the response function, nor will OPTIONS

malcolmsparks07:06:46

the method proxy also determines how the return value of the response function is interpretted

lmergen07:06:04

that makes sense

lmergen07:06:13

it appears as if my interceptor is not invoked when my :response fn returns nil, is that expected behaviour ?

malcolmsparks07:06:52

Can you post an example

lmergen07:06:40

let me first try to figure out what's going wrong then, might be that i'm at fault here

zamaterian07:06:24

Any hints on how to set a custom http header on the response ?

Rachel Westmacott08:06:07

I think you can add it into the context response.

Rachel Westmacott08:06:55

eg:

["/test" (yada/handler
               (yada/resource
                 {:methods {:get {:produces "plain/text"
                                  :response (fn [ctx]
                                              (-> ctx
                                                  :response
                                                  (assoc :status 200 :body "Hello\n")
                                                  (assoc-in [:headers "X-Custom"] "Neurodiversity")))}}}))]

lmergen08:06:15

@malcolmsparks i think i know what's going on -- a nil/404 raises an exception, which causes the error-interceptor-chain to be continued, rather than the regular interceptor-chain

borkdude18:06:39

Is it possible to get access to the ctx from the normal interceptor chain after an error has happened, e.g. get the parsed request body out of it?

borkdude18:06:45

I guess not, but just asking to be sure

borkdude18:06:11

We would like to log this for bug solving purposes

grav20:06:32

Is it correctly understood that merely emitting a lazy seq as a resource doesn’t result in a stream (ie chunked response)?

grav20:06:04

Eg:

(yada/resource {:produces "application/edn"
                           :response #(repeat 1000 {:foo 42})})