diff --git a/README.md b/README.md index f91124d..087527e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ GCDWebServer ============ -A lightweight GCD based HTTP 1.1 server for Mac & iOS apps written from scratch with the following goals in mind: -* Entirely built on [Grand Central Dispatch](http://en.wikipedia.org/wiki/Grand_Central_Dispatch) for best performance and no-hassle multithreading +GCDWebServer is a lightweight GCD based HTTP 1.1 server for Mac & iOS apps written from scratch with the following goals in mind: +* Entirely built with an event-driven design using [Grand Central Dispatch](http://en.wikipedia.org/wiki/Grand_Central_Dispatch) for maximum performance and concurrency * Well designed API for easy integration and customization * Minimal number of source files and no dependencies on third-party source code * Support for streaming large HTTP bodies for requests and responses to minimize memory usage @@ -72,12 +72,20 @@ int main(int argc, const char* argv[]) { } ``` -How it Works -============ +Using GCDWebServer +================== + +You start by creating an instance of the 'GCDWebServer' class. Note that you can have multiple web servers running in the same app as long as they listen on different ports. + +Then you add one or more "handlers" to the server: each handler gets a chance to handle an incoming web request and provide a response. Handlers are called in a LIFO queue, so the latest added handler overrides any previously added ones. + +Finally you start the server on a given port. Note that even if built on GCD, GCDWebServer still requires a runloop to be around (by default the main thread runloop is used). This is because there is no CGD API at this point to handle listening sockets, so it must be done using CFSocket which requires a runloop. However, the runloop is only used to accept the connection: immediately afterwards, the connection handling is dispatched to GCD queues. + +Understanding Requests and Responses +==================================== TBD - Advanced Example 1: Implementing HTTP Redirects ===============================================