Coder Social home page Coder Social logo

lev's Introduction

lev

Lightweight C++ wrapper for LibEvent 2 API

Build Status

LibEvent is a great library. It uses a C interface which is well designed but has a learning curve. This library, lev, is a very simple API in C++ that encapsulates commonly used functionality. It tries to stay close to the libevent API concepts except when there is confusion. It simplifies life-times of objects. The callback function signatures remain identical--but lev objects can be constructed within the callback functions.

      EvHttpRequest evreq(req);

lev is actually just a couple of header file, lev.h, and levhttp.h (if you need a httpserver). Just include it in your application and start using all the classes--no need to build or install:

class IpAddr;
class EvBaseLoop;
class EvEvent;
class EvKeyValues;
class EvBuffer;
class EvBufferEvent;
class EvConnListener;
class EvHttpUri;
class EvHttpRequest;
class EvHttpServer;

Code: An HTTP server using lev. Look at the example section for more.

  #include "lev.h"
  #include "levhttp.h"
  using namespace lev;

  static
  void onHttpHello(struct evhttp_request* req, void* arg)
  {
      EvHttpRequest evreq(req);
      evreq.output().printf("<..>Hello World!<..>");
      evreq.sendReply(200, "OK");
  }

  int main(int argc, char** argv)
  {
      EvBaseLoop base;
      EvHttpServer http(base);

      http.addRoute("/hello", onHttpHello);
      http.bind("127.0.0.1", 8080);

      base.loop();

      return 0;
  }

lev's People

Contributors

lasote avatar yasserasmi avatar

Watchers

 avatar  avatar

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.