swifter
swifter copied to clipboard
Async handling; Controller protocol; Path/handler conveniences
Hi there 👋
This PR is mostly to gauge interest in a few changes I've made to a forked copy of this package. I can very easily split this up into many PRs if there is interest in any/all of this, but first wanted to see how it was received. Thanks for having a look!
Included Changes
- Support Async/Await a. Allows use of async/await to make async extremely simple
- Fix file dir handling a. Noticed files within directories were broken
- Exclude DemoServer from package a. Slim out the package
- Add controller protocol and convenience subscript
a. Allows
GET["your/route"] = MyController.myRouteHandleri. The above would be possible for the following:struct MyController: Controller { func myRouteHandler(_ request: HttpRequest) async -> HttpResponse { - Enable registering multiple paths for a given handler
a. Allows
GET["my/first/route", "my_other_route"] = { request in } - Trim
:from request parameters a. Allowsrequest["parameterName"]vsrequest[":parameterName"]as a more convenient/intuitive accessor. i. Addresses #489
(Worth noting there are some CI issues and OS version items that will need to be sorted out if these changes are desirable for others besides myself)