CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

Epoch 0.4

Epoch 0.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Nov 2015
SPMSupports SPM

Maintained by Paulo Faria.



 
Depends on:
Venice= 0.9
HTTPParser>= 0
 

Epoch 0.4

  • By
  • Paulo Faria

Epoch

Epoch is a Venice based HTTP server for Swift 2.

Features

  • [x] No Foundation dependency (Linux ready)

Dependencies

Epoch is made of:

Related Projects

Usage

Solo

You can use Epoch without any extra dependencies if you wish.

import HTTP
import Epoch

struct HTTPServerResponder: HTTPResponderType {
    func respond(request: HTTPRequest) -> HTTPResponse {

        // do something based on the HTTPRequest

        return HTTPResponse(status: .OK)
    }
}

let responder = HTTPServerResponder()
let server = HTTPServer(port: 8080, responder: responder)
server.start()

Epoch + HTTPRouter

You’ll probably need an HTTP router to make thinks easier. Epoch and HTTPRouter were designed to work with each other seamlessly.

import HTTP
import HTTPRouter
import Epoch

let router = HTTPRouter { router in
    router.post("/users") { request in
        // do something based on the HTTPRequest
        return HTTPResponse(status: .Created)
    }

    router.get("/users/:id") { request in
        let id = request.parameters["id"]
        // do something based on the HTTPRequest and id
        return HTTPResponse(status: .OK)
    } 
}

let server = HTTPServer(port: 8080, responder: router)
server.start()

Installation

Command Line Application

To use Epoch in a command line application:

License

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