Fuzz 是一个针对 Swift 2 的 HTTP 中间件框架。
Foundation
依赖(Linux兼容)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)
要在命令行应用程序中使用 Fuzz
Fuzz 采用 MIT 许可发布。有关详细信息,请参阅 LICENSE 文件。