You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm just learning Swift at the moment. I'm coming from PHP where I use the framework Laravel a lot and I'm trying to switch to swift because I find the language much more beautiful and because it can be much more performant. And now I found Taylor and I really like it.
Looking at the source-code of Taylor and specifically the way it uses handlers / middleware I felt inspired to mix your way of doing it with Laravel's way of doing it.
What if a handler looked like this:
{
request, response, next in
// I can do all kinds of things here, before I continue to the next middleware
(request, response)=next(request, response)
// Here I can do things that need to be handled on the way out,
// after the controller has run so to speak
return(request, response)}
IMO, this is a bit cleaner than calling callback(.Continue(request, response)). Now you can choose between "continue" and "send", simply by choosing whether to call next or not.
And another nice thing about this, I read in #12 that you guys wanted a way to make sure if "Continue" was called last, it would be automatically converted to "Send". Well in this case, that is trivial. All you need to do is add a dummy handler at the end that does nothing but return the request and response immediately.
This way of doing it implied that request and response are value types, not classes, but I think one can just as easily use classes. In that case it would look like this:
{
request, response, next in
// I can do all kinds of things here, before I continue to the next middleware
next(request, response)
// Here I can do things that need to be handled on the way out,
// after the controller has run so to speak
}
What do you guys think?
The text was updated successfully, but these errors were encountered:
Hi guys,
I'm just learning Swift at the moment. I'm coming from PHP where I use the framework Laravel a lot and I'm trying to switch to swift because I find the language much more beautiful and because it can be much more performant. And now I found Taylor and I really like it.
Looking at the source-code of Taylor and specifically the way it uses handlers / middleware I felt inspired to mix your way of doing it with Laravel's way of doing it.
What if a handler looked like this:
IMO, this is a bit cleaner than calling
callback(.Continue(request, response))
. Now you can choose between "continue" and "send", simply by choosing whether to call next or not.And another nice thing about this, I read in #12 that you guys wanted a way to make sure if "Continue" was called last, it would be automatically converted to "Send". Well in this case, that is trivial. All you need to do is add a dummy handler at the end that does nothing but return the request and response immediately.
This way of doing it implied that request and response are value types, not classes, but I think one can just as easily use classes. In that case it would look like this:
What do you guys think?
The text was updated successfully, but these errors were encountered: