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
Maybe it's my personal taste, but I find it better to have both the route and the handler in the same file, so by adding those extensions:
protocolRouteHandler:HTTPHandler{func route()->HTTPRoute}extensionHTTPServer{func appendRoutes(_ routeHandlers:RouteHandler...){
routeHandlers.forEach{appendRoute($0.route(), to: $0)}}}
I'm able to write each handler like this (which I find convenient, specially when the route has placeholders, so I can write a single common function and define shared constants between the route and the request handler):
If you think it's a valuable addition, feel free to add it in the library 🍻
This is my third proposal so far (#50#49), and the fact I was able to write everything I needed as an extension denotes really good design choices on your side, so kudos for the great work! 💯
The text was updated successfully, but these errors were encountered:
Hi @gotev I've been thinking a lot about your suggestion think there is a nice declarative solution SE-0389 Attached Macros available in Swift 5.9 and later.
I'm interested in your feedback, the implementation is currently available on the branch preview/macro where handlers can annotate functions with routes:
When multiple endpoints are defined, one ends up with:
and then implementations contains only the handler:
Maybe it's my personal taste, but I find it better to have both the route and the handler in the same file, so by adding those extensions:
I'm able to write each handler like this (which I find convenient, specially when the route has placeholders, so I can write a single common function and define shared constants between the route and the request handler):
and also be able to add them all like this:
If you think it's a valuable addition, feel free to add it in the library 🍻
This is my third proposal so far (#50 #49), and the fact I was able to write everything I needed as an extension denotes really good design choices on your side, so kudos for the great work! 💯
The text was updated successfully, but these errors were encountered: