Last active
March 2, 2018 23:19
-
-
Save JacopoMangiavacchi/22bfcb491b6349202bc0ffb1020a1660 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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