TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2015 |
SPMSupports SPM | ✗ |
Maintained by Paulo Faria.
Fuzz is an HTTP middleware framework for Swift 2.
Foundation
dependency (Linux ready)struct Middleware : HTTPRequestMiddlewareType {
func respond(request: HTTPRequest) -> HTTPRequestMiddlewareResult {
// You can change the request and pass it forward
return .Next(request)
// Or you can respond early and bypass the chain
return .Respond(HTTPResponse(statusCode: 404, reasonPhrase: "Not Found"))
}
}
struct Responder : HTTPResponderType {
func respond(request: HTTPRequest) -> HTTPResponse {
// May or may not be called
return HTTPResponse(statusCode: 200, reasonPhrase: "OK")
}
}
let request = HTTPRequest(method: .GET, uri: URI(path: "/"))
let chain = Middleware() >>> Responder()
let response = chain.respond(request)
To use Fuzz in a command line application:
Fuzz is released under the MIT license. See LICENSE for details.