Last active
October 9, 2016 09:53
-
-
Save akrabat/888cb391a81cad3f656b8ffc80861091 to your computer and use it in GitHub Desktop.
Kitura "Hello world": /ping
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 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