Latest 0.1
Homepage https://github.com/Zewo/HTTPMiddleware
License MIT
Platforms ios 8.0, osx 10.9, requires ARC
Dependencies HTTP
Authors

Swift 2.2
Platforms Linux
License MIT
Slack Status

HTTPMiddleware is an HTTP middleware framework for Swift 2.2.

Features

  • [x] HTTP Request Middleware
  • [x] HTTP Response Middleware

Usage

import HTTP
import HTTPMiddleware

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 depending on the middleware
        return HTTPResponse(statusCode: 200, reasonPhrase: "OK")
    }
}

let request = HTTPRequest(method: .GET, uri: URI(path: "/"))
let chain = Middleware() >>> Responder()
let response = chain.respond(request)

Installation

$ git clone https://github.com/Zewo/uri_parser.git
$ cd uri_parser
$ make
$ dpkg -i uri_parser.deb
  • Add HTTPMiddleware to your Package.swift
import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/Zewo/HTTPMiddleware.git", majorVersion: 0, minor: 1)
    ]
)

Community

Slack

Join us on Slack.

License

HTTPMiddleware is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "HTTPMiddleware",
    "version": "0.1",
    "license": "MIT",
    "summary": "HTTP middleware framework for Swift 2 (Linux ready)",
    "homepage": "https://github.com/Zewo/HTTPMiddleware",
    "authors": {
        "Paulo Faria": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Zewo/HTTPMiddleware.git",
        "tag": "0.1"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9"
    },
    "source_files": "HTTPMiddleware/**/*.swift",
    "dependencies": {
        "HTTP": []
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This