https://github.com/tombuildsstuff/infrastructure-toolkit-swift-vapor
An Implementation of the Infrastructure Toolkit for the Vapor Web Framework
https://github.com/tombuildsstuff/infrastructure-toolkit-swift-vapor
Last synced: over 1 year ago
JSON representation
An Implementation of the Infrastructure Toolkit for the Vapor Web Framework
- Host: GitHub
- URL: https://github.com/tombuildsstuff/infrastructure-toolkit-swift-vapor
- Owner: tombuildsstuff
- License: mit
- Created: 2016-08-02T05:42:16.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-12T15:03:40.000Z (over 9 years ago)
- Last Synced: 2025-02-07T14:46:11.552Z (over 1 year ago)
- Language: Swift
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Infrastructure Toolkit (Swift) for Vapor
This is an implementation of the [Infrastructure Toolkit](https://github.com/tombuildsstuff/infrastructure-toolkit-swift) for the Vapor web framework.
There's a [proper description](https://github.com/tombuildsstuff/infrastructure-toolkit-swift#fundamentals) on the [Infrastructure Toolkit repo](https://github.com/tombuildsstuff/infrastructure-toolkit-swift) - go check it out.
## Usage
### Step 1: Create a Monitor
```
import Foundation
import InfrastructureToolkit
@objc
public class ExampleServiceStatusMonitor : NSObject, ServiceStatusMonitor {
public var name : String {
get { return "Example" }
}
public func checkIsHealthy() throws -> ServiceStatusResult {
let summary = "oh hai"
var properties = [String: String]()
properties["foo"] = "bar"
properties["hello"] = "there"
let metaData = ServiceStatusResultMetaData(summary, properties)
return ServiceStatusResult(name: self.name, successful: true, metaData: metaData)
}
}
```
### Step 2: Hook up the Routing
```
import HTTP
import InfrastructureToolkitVapor
import Vapor
let drop = Droplet(providers: [])
let monitors = [ SomeExampleMonitor() ]
drop.registerInfrastructureToolkit(monitors: monitors)
drop.get("/hello-world") {
(request: Request) throws -> ResponseRepresentable in
return "Hello World"
}
let port = 5000
drop.serve()
```
### Step 3: Build & Run
```
vapor build
vapor run
```
### Step 4: Try it out:
- /service-status
- /service-status/{monitorName}
## Licence
MIT