{"id":13420543,"url":"https://github.com/ayanko/libevent","last_synced_at":"2025-04-23T02:48:49.256Z","repository":{"id":1879136,"uuid":"2804687","full_name":"ayanko/libevent","owner":"ayanko","description":"C extension to libevent library","archived":false,"fork":false,"pushed_at":"2012-05-11T12:29:07.000Z","size":546,"stargazers_count":33,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-23T02:48:43.881Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ayanko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-11-18T18:46:54.000Z","updated_at":"2024-12-31T15:37:17.000Z","dependencies_parsed_at":"2022-09-09T09:01:56.658Z","dependency_job_id":null,"html_url":"https://github.com/ayanko/libevent","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayanko%2Flibevent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayanko%2Flibevent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayanko%2Flibevent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayanko%2Flibevent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayanko","download_url":"https://codeload.github.com/ayanko/libevent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250360249,"owners_count":21417717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:01:35.877Z","updated_at":"2025-04-23T02:48:49.236Z","avatar_url":"https://github.com/ayanko.png","language":"C","funding_links":[],"categories":["TODO scan for Android support in followings"],"sub_categories":[],"readme":"## Libevent\n\nC extension to [libevent](http://libevent.org/) library.\n\n## Description\n\nThe nice feature of libevent is it already contains build in HTTP server (evhttp).\n\nCurrently libevent extension implements mostly http server.\n\n## Dependencies\n\n* libevent v2\n\n## Documentation\n\nPlease read [libevent rubydoc](http://rubydoc.info/github/ayanko/libevent/frames)\n\n## Installation\n\n    gem install libevent\n\n## Using Libevent HTTP server\n\nCheck `samples` directory\n\n### From scratch\n\nSimple server\n\n    require \"libevent\" \n\n    # create event base\n    base = Libevent::Base.new\n\n    # create http server instance\n    http = Libevent::Http.new(base)\n\n    # bind socket\n    http.bind_socket(\"0.0.0.0\", 15015)\n\n    # set handler\n    http.handler do |request|\n      request.send_reply(200, {}, [\"Hello World\\n\"])\n    end\n\n    # catch SIGINT\n    base.trap_signal(\"INT\") { base.exit_loop }\n \n    # start libevent loop\n    base.dispatch\n\nCheck with curl\n\n    $ curl -v http://localhost:15015\n    \u003e GET / HTTP/1.1\n    \u003e User-Agent: curl/7.22.0 (x86_64-unknown-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.0e zlib/1.2.5 libssh2/1.3.0\n    \u003e Host: localhost:15015\n    \u003e Accept: */*\n    \u003e \n    \u003c HTTP/1.1 200 OK\n    \u003c Transfer-Encoding: chunked\n    \u003c Date: Fri, 18 Nov 2011 19:09:04 GMT\n    \u003c Content-Type: text/html; charset=ISO-8859-1\n    \u003c \n    Hello World\n\n### Server with virtual hosts\n\n    require \"libevent\"\n\n    Libevent::Builder.new do\n\n      server \"0.0.0.0\", 3000 do |http|\n\n\thttp.handler do |request|\n\t  case request.get_uri_path\n\t  when '/hello'\n\t    request.send_reply 200, { 'Content-\u003eType' =\u003e 'text/plain'},  [ \"Hello World\" ]\n\t  when '/api'\n\t    request.send_reply 200, { 'Content-\u003eType' =\u003e 'application/json'},  [ \"{\\\"version\\\":\\\"1.0\\\"}\" ]\n\t  else\n\t    request.send_error 404, \"Nothing Found\"\n\t  end\n\tend\n\n\thttp.vhost \"blog.local\" do |host|\n\t  host.handler do |request|\n\t    request.send_reply 200, {}, [\"It's blog\"]\n\t  end\n\tend\n\n\thttp.vhost \"wiki.local\" do |host|\n\t  host.handler do |request|\n\t    request.send_reply 200, {}, [\"It's wiki\"]\n\t  end\n\tend\n\n\thttp.vhost \"*.local\" do |host|\n\t  host.handler do |request|\n\t    request.send_error 404, \"Please use blog.local or wiki.local\"\n\t  end\n\tend\n\n      end\n\n      server \"0.0.0.0\", 3001 do |http|\n\thttp.handler do |request|\n\t  request.send_reply 200, { 'Content-\u003eType' =\u003e 'text/plain'},  [ \"Hello World 3001\" ]\n\tend\n      end\n\n      signal(\"INT\") do\n\tbase.exit_loop\n      end\n\n      signal(\"HUP\") do\n\tKernel.puts \"HUP received ...\"\n      end\n\n      dispatch\n\n    end\n\n### Serve Rails application\n\nAdd to `Gemfile`\n\n    gem \"libevent\", :require =\u003e false\n\nUpdate gems\n\n    $ bundle install\n\nRun application\n\n    $ script/rails s Libevent\n\nOr via rackup\n\n    $ bundle exec rackup -s Libevent -p 3000\n\n### Serve Rack application\n\nCheck rack handler `rack/handler/libevent.rb`\n\n\n## References\n\n* [libevent2 documentation](http://www.wangafu.net/~nickm/libevent-2.0/doxygen/html/index.html)\n* [libevent ruby binding documentation](http://rubydoc.info/github/ayanko/libevent/master/file/README.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayanko%2Flibevent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayanko%2Flibevent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayanko%2Flibevent/lists"}