Skip to content

Commit d7cd3ce

Browse files
author
Thomas Vendetta
committed
Better Readme
1 parent dbff675 commit d7cd3ce

2 files changed

Lines changed: 56 additions & 48 deletions

File tree

README

Lines changed: 0 additions & 48 deletions
This file was deleted.

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# eventmachine_httpserver
2+
3+
## EM::HttpServer vs Thin
4+
5+
+careo | is there a 25 word version of how it differs from thin?
6+
+tmm1 | good question.. its probably faster, but only because it doesn't have a real http parser like thin
7+
+wyhaines | It is faster. It's more of an nginx style parser than the mongrel, grammar based parser.
8+
+careo | so perhaps a better fit for putting an http interface on top of a bunch of already-evented code?
9+
+wyhaines | careo: It depends. There are very valid arguments for using an RFC-compliant parser a lot of the time.
10+
+wyhaines | But, yeah, sometimes being strictly RFC compliant isn't something that you care about.
11+
12+
## Installing
13+
14+
### Without Bundler
15+
sudo gem install eventmachine_httpserver
16+
17+
### With bundler
18+
19+
gem 'eventmachine_httpserver', :require => 'evma_httpserver'
20+
21+
## Usage example
22+
require 'eventmachine'
23+
require 'evma_httpserver'
24+
25+
class MyHttpServer < EM::Connection
26+
include EM::HttpServer
27+
28+
def post_init
29+
super
30+
no_environment_strings
31+
end
32+
33+
def process_http_request
34+
# the http request details are available via the following instance variables:
35+
# @http_protocol
36+
# @http_request_method
37+
# @http_cookie
38+
# @http_if_none_match
39+
# @http_content_type
40+
# @http_path_info
41+
# @http_request_uri
42+
# @http_query_string
43+
# @http_post_content
44+
# @http_headers
45+
46+
response = EM::DelegatedHttpResponse.new(self)
47+
response.status = 200
48+
response.content_type 'text/html'
49+
response.content = '<center><h1>Hi there</h1></center>'
50+
response.send_response
51+
end
52+
end
53+
54+
EM.run{
55+
EM.start_server '0.0.0.0', 8080, MyHttpServer
56+
}

0 commit comments

Comments
 (0)