[swift-server-dev] HTTP API v0.1.0
Georgios Moschovitis
george.moschovitis at icloud.com
Tue Nov 7 05:30:08 CST 2017
Thanks for the little example, ver helpful. A few naming suggestions stuck me though:
From:
```
import Foundation
import HTTP
func hello(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
response.writeHeader(
status: .ok,
headers: [ "Content-Type": "text/html" ])
)
response.writeBody("Hello, World!\n")
response.done()
return .discardBody
}
```
to:
```
import Foundation
import HTTPServer
func hello(request: HTTPRequestHead, response: HTTPResponseWriter ) -> HTTPRequestBodyProcessing {
response.writeHead(
status: .ok,
headers: [ "Content-Type": "text/html" ])
)
response.writeBody("Hello, World!\n")
response.close()
return .discardBody
}
```
what do you think?
> On 30 Oct 2017, at 12:08 PM, Helge Heß via swift-server-dev <swift-server-dev at swift.org> wrote:
>
> FYI: I updated my Apache implementation of the HTTP API:
>
> https://github.com/modswift/http/tree/implementation/mod_swift
>
> and wrote up a small blog post on how to use HTTP 0.1.0 with the included server, as well as the above:
>
> http://www.alwaysrightinstitute.com/http-010/
>
> Have fun!
>
> hh
>
> P.S.: I also have a GCD based async implementation of the API almost ready. Stay tuned.
>
> _______________________________________________
> swift-server-dev mailing list
> swift-server-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-server-dev
More information about the swift-server-dev
mailing list