-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map function into enter, not into handler #14
Comments
Interceptor enter differs from handler in that interceptor enter is called and is expected to returns ctx, where as the handler is called with request and expected to return response. If we change Perhaps what ever is last in queue is assumed to be handler? Or, we could make it so that every element in queue is an interceptor, and we just provide utility to convert handler into interceptor and require that the caller does the conversion. Something like: (s/execute [some-interceptor other-interceptor (handler->interceptor my-handler)]) What do you think? |
I think it's a good idea. And for ergonomics, |
It would be more symmetric and principled to have both Forcing the handler to be of interceptor type does not make much sense to me since it is a special case anyway because the context turns around and/or request is switched to response. |
One thing I've been wondering: does the interceptor pattern inherently imply that the context should contain a Or is it more general, does the interceptor pattern only imply a context goes through the interceptors one way, then back another, and I think answering this question would help answer how a function should be interpreted as an interceptor. If there is no separate concept of request/response, then clearly a function shouldn't work be a request->response handler. I have been thinking about using the interceptor pattern. I currently have the request just as subset of the context itself. There is no real "standard" defining my request so I didn't initially see a need to seperate it from surrounding context. The context is built up from the chain of interceptors, then at the end I pick out what I need to make the request and return back up the chain. For what it's worth, I'm beginning to think maybe this is bad and I more clearly define my "request" and put it into a |
The handler could also be a function |
There is a related issue of making the request & response optional: #18 |
Also #15 |
If functions would be mapped into interceptor enter, instead of special handler case, it would be easier to write one-way chains:
Instead of:
one could say:
... inlined:
https://github.com/metosin/sieppari/blob/develop/src/sieppari/interceptor.cljc#L30-L35
The text was updated successfully, but these errors were encountered: