November 2018
Intermediate to advanced
404 pages
10h 16m
English
All the implementations of endpoints are stored in the /Routes directory. In Kitura's basic template, a health check endpoint (/Routes/HealthRoutes.swift) is created as an example:
// File: /Routes/HealthRoutes.swiftimport LoggerAPIimport Healthimport KituraContractsfunc initializeHealthRoutes(app: App) { app.router.get("/health") { (respondWith: (Status?, RequestError?) -> Void) -> Void in if health.status.state == .UP { respondWith(health.status, nil) // [1] } else { respondWith(nil, RequestError(.serviceUnavailable, body: health.status)) // [2] } }}
The Health endpoint exposes the health of the application. It responds to the health check request with a closure that returns a health.status structure: ...
Read now
Unlock full access