Skip to content

Instantly share code, notes, and snippets.

@TyrfingMjolnir
Created December 4, 2016 23:53
Show Gist options
  • Save TyrfingMjolnir/7189c69a379499c98a76e40ac9cca4db to your computer and use it in GitHub Desktop.
Save TyrfingMjolnir/7189c69a379499c98a76e40ac9cca4db to your computer and use it in GitHub Desktop.
swift REST API basic skeleton
$ cat main.swift
import Kitura
import HeliumLogger
// Initialize HeliumLogger
HeliumLogger.use()
// Create a new router
let router = Router()
// Handle HTTP GET requests to /
router.get("/") {
request, response, next in
response.send("Hello, World!")
next()
}
let itemRouter = router.route(”/item”)
setupItem(router: itemRouter)
// Add an HTTP server and connect it to the router
Kitura.addHTTPServer(onPort: 8090, with: router)
// Start the Kitura runloop (this call never returns)
Kitura.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment