diff --git a/.travis.yml b/.travis.yml index f271211..054b078 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: objective-c +osx_image: xcode7 before_install: - gem install cocoapods --no-document script: +- swiftc Nest.swift - pod lib lint diff --git a/Nest.podspec b/Nest.podspec index 0634b33..eaaada5 100644 --- a/Nest.podspec +++ b/Nest.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |spec| spec.name = 'Nest' - spec.version = '0.1.0' + spec.version = '0.2.0' spec.summary = 'Swift Web Server Gateway Interface.' spec.homepage = 'https://github.com/nestproject/' spec.license = { :type => 'BSD', :file => 'LICENSE' } spec.author = { 'Kyle Fuller' => 'kyle@fuller.li' } spec.social_media_url = 'http://twitter.com/kylefuller' - spec.source = { :git => 'https://github.com/nestproject/Nest.git', :tag => "#{spec.version}" } + spec.source = { :git => 'https://github.com/nestproject/Nest.git', :tag => spec.version } spec.source_files = 'Nest.swift' spec.requires_arc = true spec.ios.deployment_target = '8.0' diff --git a/Nest.swift b/Nest.swift index ee7d83f..0c3c822 100644 --- a/Nest.swift +++ b/Nest.swift @@ -17,3 +17,5 @@ public protocol ResponseType { var body:String? { get } } +public typealias Application = RequestType -> ResponseType + diff --git a/README.md b/README.md index 312a6b9..c3ab311 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ The interface must not make use any external frameworks and only depend on core A simple Hello World web application using the Nest interface: ```swift -func application(env:[String:AnyObject]) -> (String, [(String, String)], String?) { - return ("200 OK", [("Content-Type", "text/plain")], "Hello World") +func application(request:RequestType) -> ResponseType { + return Response(.Ok, body: "Hello World") } ``` @@ -46,7 +46,7 @@ Along with providing a specification, Nest also provides a [test suite](https:// ### Other -- [Inquiline](https://github.com/nestproject/Inquiline) - A collection of constants and typealiases to aid dealing with Nest. +- [Inquiline](https://github.com/nestproject/Inquiline) - A standard implementation of RequestType and ResponseType. - [Padlock](https://github.com/nestproject/Padlock) - Nest middleware to lockup your web application. ## See Also diff --git a/Specification.md b/Specification.md index 4a04f55..9ef15cf 100644 --- a/Specification.md +++ b/Specification.md @@ -1,21 +1,25 @@ --- -Version: 0.1.0 +Version: 0.2.0 --- # Nest Specification -There are two components that make up the Nest interface, the “server” or “gateway” component, and the “application” or “framework” component. +There are two components that make up the Nest interface, the “server” or +“gateway” component, and the “application” or “framework” component. The server component invokes the function that is provided by the application. ## Application -A Nest application is a simple Swift function that takes exactly one argument, the environment. It returns a tuple (the response) containing exactly three values, the status, headers and the body. +A Nest application is a simple Swift function that takes exactly one argument, +an object or structure that conforms to RequestType. It returns an instance +of a ResponseType which contains exactly three values, the status, headers +and the body. The full type of the application function is as follows: ```swift -([String:AnyObject]) -> (String, [(String, String)], String?) +RequestType -> ResponseType ``` ## Server @@ -23,14 +27,30 @@ The full type of the application function is as follows: The server or gateway invokes the applications function once for each request from a client. -## Details +```swift +public typealias Header = (String, String) +``` -### Environment +## RequestType -- `REQUEST_METHOD` (String) - The HTTP request method, such as “GET” or “POST”. -- `PATH_INFO` (String) - The HTTP Path. +```swift +public protocol RequestType { + var method:String { get } + var path:String { get } + var headers:[Header] { get } + var body:String? { get } +} +``` -### The Response +### ResponseType + +```swift +public protocol ResponseType { + var statusLine:String { get } + var headers:[Header] { get } + var body:String? { get } +} +``` #### Status (`String`)