A Vapor middleware for including the domain in routing.
Add HostRouter
as a dependency in your Package.swift
file to start using it. Then, add import HostRouter
to any file you wish to use the library in.
Please check the releases for recommended versions.
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "4.90.0"),
.package(url: "https://github.com/mochidev/HostRouter.git", .upToNextMinor(from: "0.2.0")),
],
...
targets: [
.executableTarget(
name: "MyPackage",
dependencies: [
.product(name: "Vapor", package: "vapor")
.product(name: "HostRouter", package: "HostRouter")
]
)
]
HostRouter
extends Vapor's routing capabilities by allowing you to include routes for the host domain along with the resource. This makes it easy to partition a domain running on a single server with dynamic routing for different users or services.
Host Router
was heavily inspired by by a post by @andreasley on the Vapor repo, along with Vapor's own DefaultResponder
.
Contribution is welcome! Please take a look at the issues already available, or start a new discussion to propose a new feature. Although guarantees can't be made regarding feature requests, PRs that fit within the goals of the project and that have been discussed beforehand are more than welcome!
Please make sure that all submissions have clean commit histories, are well documented, and thoroughly tested. Please rebase your PR before submission rather than merge in main
. Linear histories are required, so merge commits in PRs will not be accepted.
To support this project, consider following @dimitribouniol on Mastodon, listening to Spencer and Dimitri on Code Completion, or downloading Dimitri's wife Linh's app, Not Phở.