Skip to content

Instantly share code, notes, and snippets.

@akrabat
Last active October 9, 2016 09:53
Show Gist options
  • Save akrabat/888cb391a81cad3f656b8ffc80861091 to your computer and use it in GitHub Desktop.
Save akrabat/888cb391a81cad3f656b8ffc80861091 to your computer and use it in GitHub Desktop.
Kitura "Hello world": /ping
import Kitura
import SwiftyJSON
let router = Router()
router.get("/ping") { _, response, next in
// see http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
let date = Date()
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_GB")
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
response.status(.OK).send(json: JSON(["ack" : formatter.string(from: date)]))
next()
}
Kitura.addHTTPServer(onPort: 8090, with: router)
Kitura.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment