Is there a good way to instrument a plug conn with a function that only gets called just before it gets sent?
Suppose I want to validate my own output and have it crash if it fails to satisfy some schema constraints in dev and test environments.
Is there a good way to instrument a plug conn with a function that only gets called just before it gets sent?
Suppose I want to validate my own output and have it crash if it fails to satisfy some schema constraints in dev and test environments.
awesome thanks! I swear I looked down that module documentation three times
Only gotcha I ran into there is the callback you register won’t be called in the event the client hangs up prematurely. Sounds like that’s fine for your use case, just dropping this comment for folks that find this thread later in case it’s relevant to them
good catch! I think the only way to trap that is to monitor the handling process.
Look into cowboy stream handlers! I actually think that’s the best way to go personally It’s worked well for me so far:crossed_fingers:Bit of a learning curve though.