-
Notifications
You must be signed in to change notification settings - Fork 15
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
Difficulty using siesta with certain use cases. #11
Comments
I agree. Do you think it might be possible with nested services? |
That would be another possible route, but for the small services that we typically write, that might be overkill. |
I think I mentioned this before, but I think the Right now we run through the preware and then figure out which handler to choose: Lines 58 to 66 in 653617e
|
That shouldn't be so bad though. Right? In some way it might make it |
Yep. Although I'm not sure how we can use your syntax :). |
Yeah. I was thinking about that. I can see through to how I would implement |
Devil's advocate here 😈 : I started thinking that it might be nice to just explicitly call out the pre/actual/post handlers: func (s *Service) service.Route(verb, route, description string, preHandler, handler, postHandler Handler) But then it occurred to me that we could achieve this functionality and simplify the current interface significantly by just 1) removing AddPre() and AddPost() and 2) using Compose. So a routing call would look like service.Route("GET", "/fruit", "Gets a fruit", siesta.Compose(fruitParser,fruitDbRetriever,fruitShiner)) So 😈 asks: Is the cool part really just the fact that we can now compose handlers together and keep track of a context between them? |
Yeah, you're right. I don't think you have to use those chains. |
Consider a service that has several related endpoints and there is a ton of shared setup for these endpoints (authenticate user, grab appropriate databases, etc.). Then it's good to put these into the "pre" middleware. But what if you've got like 1 or 2 endpoints that don't need to do all of this? Is there any way that you can omit the preware? Otherwise we're doing a lot of work for no reason.
One idea:
The text was updated successfully, but these errors were encountered: