Closed qszhu closed 5 years ago
It's just not designed for that. You have to define token param explicitly in every endpoint. However, shared before
block should work even with params.query.token
in it.
I used context.request.query
as a workaround for now. What I was thinking is that such "middleware"s should take care of their interested params respectively, so that these params don't clutter with the ones required by real business logic.
On a second thought, I think what you said is also beneficial. Listing all the params explicitly in an endpoint could make maintenance much easier.
I'm trying to do some check in each request:
To check:
This works. To reuse some code, I extracted a module:
This one crashes.
Output
``` Invalid memory access (signal 11) at address 0x4 [0x10d1af66b] *CallStack::print_backtrace:Int32 +107 [0x10d183375] __crystal_sigfault_handler +181 [0x7fff5f894b5d] _sigtramp +29 [0x10d18d375] *String#empty?:Bool +5 [0x10d19415e] *String#pretty_printIs this a limitation of Crystal? Or am I just doing it the wrong way?