Aeon is a GCD based HTTP server for Swift 2.
- No
Foundation
dependency (Linux ready)
Aeon is made of:
- TCPIP - TCP/IP
- GrandCentralDispatch - GCD wrapper
- URI - URI
- HTTP - HTTP request/response
- HTTPParser - HTTP parser
- HTTPRouter - HTTP router
- HTTPMiddleware - HTTP middleware framework
You can use Aeon without any extra dependencies if you wish.
import HTTP
import Aeon
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()
You'll probably need an HTTP router to make thinks easier. Aeon and HTTPRouter were designed to work with each other seamlessly.
import HTTP
import HTTPRouter
import Aeon
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()
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 0.39.0+ is required to build Aeon.
To integrate Aeon into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/Zewo/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod 'Aeon', '0.3'
Don't forget
source 'https://github.com/Zewo/Specs.git'
. This is very important. It should always come before the official CocoaPods repo.
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate Aeon into your Xcode project using Carthage, specify it in your Cartfile
:
github "Zewo/Aeon" == 0.3
To use Aeon in a command line application:
- Install the Swift Command Line Application Xcode template
- Follow Cocoa Pods or Carthage instructions.
Join us on Slack.
Aeon is released under the MIT license. See LICENSE for details.