Skip to content

Instantly share code, notes, and snippets.

@tanner0101
Last active June 13, 2016 02:36
Show Gist options
  • Save tanner0101/47b78762916acc432f9925ad4cc7eae6 to your computer and use it in GitHub Desktop.
Save tanner0101/47b78762916acc432f9925ad4cc7eae6 to your computer and use it in GitHub Desktop.
Vapor Benchmark
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