A small, dependency-free routing library for Swift
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-09 09:52:53 +00:00
docs Initial commit: Router and Route 2026-04-21 09:52:52 +00:00
Sources/Atlas Add a note about route priorities (follow-up) 2026-08-09 09:52:53 +00:00
Tests Initial commit: Router and Route 2026-04-21 09:52:52 +00:00
README.md Initial commit: Router and Route 2026-04-21 09:52:52 +00:00

Atlas

A small, dependency-free routing library for Swift. 🗺️

Atlas

Atlas turns a URL into a value your code can switch on. It does not do networking, it does not do views, and it will never grow a plugin system.

Installing

dependencies: [
    .package(url: "https://example.com/atlas.git", from: "2.1.0")
]

Using it

let router = Router {
    Route("/users/:id") { UserRoute(id: $0["id"]) }
    Route("/posts/:slug/comments") { CommentsRoute(slug: $0["slug"]) }
}

switch router.match(url) {
case .user(let id):  show(user: id)
case .comments(let slug): show(comments: slug)
case .none: showNotFound()
}

What it supports

Pattern Matches Captures
/users/:id /users/42 id = "42"
/files/*path /files/a/b/c.txt path = "a/b/c.txt"
/posts/:slug /posts/hello-world slug
/health /health only

Status

  • Path parameters
  • Wildcard segments
  • Query strings
  • Route priorities — see #2
  • A macro-based DSL

Thanks to @reviewer for the report in #1.

Licence

MIT.