Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates a simple Vapor application with routes for listing and creating Todo items.
import Vapor
struct Todo: Content {
var id: UUID?
var title: String
var completed: Bool
}
var todos: [Todo] = []
func routes(_ app: Application) throws {
app.get("/todos") { req -> [Todo] in
return todos
}
app.post("/todos") { req -> Todo in
let todo = try req.content.decode(Todo.self)
todos.append(todo)
return todo
}
}
let app = Application()
defer { app.shutdown() }
try routes(app)
try app.run()Vapor is a server-side Swift web framework designed for building fast, safe, and scalable web applications and APIs, fully leveraging Swift’s type safety and performance.
Origin & Creator
Created by Tanner Nelson in 2016, maintained by the Vapor community.
Industrial Note
Vapor is popular for Swift developers building server-side applications, REST APIs, and real-time services, especially in ecosystems that favor Swift, like Apple platforms.