Sha256: 37d3761e6d067e9562177bfd914a11223f3a7078328ed99001dca6ff746c61a5
Contents?: true
Size: 1.1 KB
Versions: 10
Compression:
Stored size: 1.1 KB
Contents
import Kitura import KituraNet import StatsD import LoggerAPI import SwiftyJSON import <%= application_name %> class Routing { let statsD: StatsDProtocol let config: JSON init(statsD: StatsDProtocol, config: JSON) { self.statsD = statsD self.config = config } func setupRouter() -> Router { let router = Router() setupHealthRoutes(router: router, path: "/v1/health") return router } // setup the router with our handlers private func setupHealthRoutes(router: Router, path: String) { router.get(path) { request, response, next in HealthHandler.handle(statsD: self.statsD) { (status: HTTPStatusCode, data: JSON?) in self.sendResponse(response: response, status: status, data: data) } // execute next middleware in sequence next() } } private func sendResponse(response: RouterResponse, status: HTTPStatusCode, data: JSON?) { response.status(status) if data != nil { do { try response.send(json: data!).end() } catch { Log.error("Error sending response") } } } }
Version data entries
10 entries across 10 versions & 1 rubygems