0Pricing
Swift Academy · Lesson

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

  1. Routing and Request Handling
  2. Content and JSON Encoding
  3. Fluent ORM and Models
  4. Middleware and Authentication
← Back to Swift Academy