Skip to content

Commit 5633bb7

Browse files
committed
Initial specification
0 parents  commit 5633bb7

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

LICENSE

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright (c) 2014, Kyle Fuller
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Nest - Swift Web Server Gateway Interface
2+
3+
Nest provides a minimal interface between web servers supporting Swift and web applications or frameworks. It’s designed to prevent tight coupling between web servers and web applications or frameworks. To enable the use of any framework or application with any server.
4+
5+
## Quick Links
6+
7+
- [Specification](Specification.md)
8+
9+
## Rationale and Goals
10+
11+
The primary goal of Nest is to enable the use of any framework or application with any server. To prevent tight coupling between web servers and web applications or frameworks.
12+
13+
Nest provides a minimal interface supporting every feature in HTTP. It must be extremely simple, and easy to implement for both servers and web applications.
14+
15+
The interface must not make use any external frameworks and only depend on core Swift language features.
16+
17+
## Example Application
18+
19+
A simple Hello World web application using the Nest interface:
20+
21+
```swift
22+
func application(env:[String:AnyObject]) -> (String, [(String, String)], String) {
23+
return ("200 OK", [("Content-Type", "text/plain")], "Hello World")
24+
}
25+
```
26+
27+
## Testing
28+
29+
Along with providing a specification, Nest also provides a test suite to ensure that a server correctly follows the specification, and to aid development of web servers.
30+
31+
## Implementations
32+
33+
There are no current implementations.
34+
35+
## License
36+
37+
Nest is licensed under the BSD license. See [LICENSE](LICENSE) for more information.
38+

Specification.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
Version: 0.1.0
3+
---
4+
5+
# Nest Specification
6+
7+
There are two components that make up the Nest interface, the “server” or “gateway” component, and the “application” or “framework” component.
8+
9+
The server component invokes the function that is provided by the application.
10+
11+
## Application
12+
13+
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.
14+
15+
The full type of the application function is as follows:
16+
17+
```swift
18+
([String:AnyObject]) -> (String, [(String, String)], String)
19+
```
20+
21+
### Environment
22+
23+
- `REQUEST_METHOD`
24+
- `PATH_INFO`
25+
26+
### The Response
27+
28+
#### Status (`String`)
29+
30+
This is an HTTP status. It must be a string containing a 3-digit integer result code followed by a reason phrase. For example, `200 OK`.
31+
32+
#### Headers (`[(String, String)]`)
33+
34+
The headers is an array of tuples containing the key and value for each HTTP header for the server to send in the returned order.
35+
36+
#### Body (`String`)
37+
38+
The body must be a String.
39+
40+
## Server
41+
42+
The server or gateway invokes the applications function once for each request
43+
from a client.
44+

0 commit comments

Comments
 (0)