Last active
June 13, 2016 02:36
-
-
Save tanner0101/47b78762916acc432f9925ad4cc7eae6 to your computer and use it in GitHub Desktop.
Vapor Benchmark
This file contains hidden or 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 Vapor | |
import Fluent | |
import FluentSQLite | |
let app = Application() | |
do { | |
let driver = try SQLiteDriver(path: "/home/helper/database/test.sqlite") | |
Database.default = Database(driver: driver) | |
} catch { | |
print("Could not open SQLite database: \(error)") | |
} | |
app.get("plaintext") { request in | |
return "Hello, world!" | |
} | |
app.get("json") { request in | |
return JSON([ | |
"array": [1, 2, 3], | |
"dict": ["one": 1, "two": 2, "three": 3], | |
"int": 42, | |
"string": "test", | |
"double": 3.14, | |
"null": nil | |
]) | |
} | |
app.get("sqlite-fetch") { request in | |
guard let user = try User.random() else { | |
throw Abort.notFound | |
} | |
return user | |
} | |
app.globalMiddleware = [] | |
app.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment