Routing and Request Handling
Define routes and handle HTTP requests.
What Is Vapor?
Vapor is a popular server-side Swift web framework built on SwiftNIO. It lets you write HTTP backends — APIs, websites — entirely in Swift, sharing language and even models with your iOS app.
import Vapor
let app = try await Application.make(.detect())The Application and Routes
The Application object is the heart of a Vapor server. You register routes on it: mappings from an HTTP method and path to a handler closure that returns a response.
app.get("hello") { req in
"Hello, world!"
}All lessons in this course
- Routing and Request Handling
- Content and JSON Encoding
- Fluent ORM and Models
- Middleware and Authentication