Git Product home page Git Product logo

evma_httpserver's Introduction

= eventmachine_httpserver

== EM::HttpServer vs Thin

     +careo | is there a 25 word version of how it differs from thin?
      +tmm1 | good question.. its probably faster, but only because it doesn't have a real http parser like thin
  +wyhaines | It is faster.  It's more of an nginx style parser than the mongrel, grammar based parser.
     +careo | so perhaps a better fit for putting an http interface on top of a bunch of already-evented code?
  +wyhaines | careo: It depends.  There are very valid arguments for using an RFC-compliant parser a lot of the time.
  +wyhaines | But, yeah, sometimes being strictly RFC compliant isn't something that you care about.

== Usage example

  require 'eventmachine'
  require 'evma_httpserver'

  class MyHttpServer < EM::Connection
    include EM::HttpServer

     def post_init
       super
       no_environment_strings
     end

    def process_http_request
      # the http request details are available via the following instance variables:
      #   @http_protocol
      #   @http_request_method
      #   @http_cookie
      #   @http_if_none_match
      #   @http_content_type
      #   @http_path_info
      #   @http_request_uri
      #   @http_query_string
      #   @http_post_content
      #   @http_headers

      response = EM::DelegatedHttpResponse.new(self)
      response.status = 200
      response.content_type 'text/html'
      response.content = '<center><h1>Hi there</h1></center>'
      response.send_response
    end
  end

  EM.run{
    EM.start_server '0.0.0.0', 8080, MyHttpServer
  }

evma_httpserver's People

Contributors

tmm1 avatar raggi avatar alor avatar cmdrkeene avatar fborgnia avatar gdb avatar igrigorik avatar skaes avatar meh avatar

Watchers

James Cloos avatar  avatar

Forkers

nobelbiz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.