Swiftpack.co - matthewlui/VaporRouteBuilder as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by matthewlui.
matthewlui/VaporRouteBuilder 0.1.2
Provide SwiftUI Liked Route syntax for Vapor using result builder
⭐️ 0
🕓 6 hours ago
.package(url: "https://github.com/matthewlui/VaporRouteBuilder.git", from: "0.1.2")


Provide SwiftUI Liked Route syntax for Vapor using result builder. This library provide only a tiny wrapper of @resultBuilder to allow you to write declarative route

For example, in vanilla vapor controller you might write like this:

struct TodoController: RouteCollection {
    func boot(routes: RoutesBuilder) throws {
        let todos = routes.grouped("todos")
        todos.get(use: index)
        let protected = todos.grouped(MyJWT.authenticator())
        protected.post(use: create)
        protected.group(":todoID") { todo in
            todo.delete(use: delete)

With VaporRouteBuilder you can write the following much more clean and explicit routing code:

struct TodoController: RouteCollection {
    var routes: [BuildableRoute] {
        Grouped("todo") {
            Get(use: index)
            Grouped(MyJWT.authenticator()) {
                Post { req -> HTTPResult in .ok }
                Grouped(":todoID") {
                    Deleted(use: delete)


Stars: 0
Last commit: 11 hours ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.


Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics