Skip to content

Instantly share code, notes, and snippets.

@JacopoMangiavacchi
Last active March 2, 2018 23:19
Show Gist options
  • Save JacopoMangiavacchi/22bfcb491b6349202bc0ffb1020a1660 to your computer and use it in GitHub Desktop.
Save JacopoMangiavacchi/22bfcb491b6349202bc0ffb1020a1660 to your computer and use it in GitHub Desktop.
import Foundation
struct User : Codable {
let firstName: String
let lastName: String
let id: Int
}
let users = [User(firstName: "John", lastName: "Doe", id: 1),
User(firstName: "Jane", lastName: "Doe", id: 2)]
let router = Router()
router.get("/users") {
return users
}
router.get("/user/0") {
return users[0]
}
let server = Server(host: "::1", port: 8888, with: router)
server.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment