Giter Club home page Giter Club logo

evhttp's Introduction

EvHttp

Introduction

This project is a cpp http server lib, wrapped of libevent.

It provides some basic http server features like handler regist, url/header/body parse, set response code/header/body and so on.

More information on Straka's blog

Feature

  • Based on libevent.
  • No c interface exposed.
  • User friendly interface.

Server Example

#include "EvHttpServ.h"
#include "Utilis/Defer.h"
#include "Utilis/Logger.h"

using namespace Network;

int main()
{
    Utilis::Logger::GetInstance()->StartLogging();
    Utilis::DEFER([] { Utilis::Logger::GetInstance()->StopLogging(); });

    EvHttpServ Serv("0.0.0.0\0", 8077);
    Serv.RegistHandler("/hi/testget", [](EvHttpResp *resp){resp->QuickResponse(200,"Hello World!\n");});

    Serv.Start();
    return 0;
}

NOTE

More examples can be found in folder "example".

Post, Put, Delete and Options methods are NOT supported yet.

It is recommended to use g++ 4.9+ to support c++11 features better.

Usage

  1. Download: git clone --recursive https://github.com/atp798/EvHttp.git

  2. Build: mkdir build && cd build && cmake ../ && make

  3. Run sample: ./EvHttpExample1

  4. Test the http server: curl -X GET x.x.x.x:8077/hi/testget. The ip address 'x.x.x.x' should be replaced by the server ip address.

TODO list

  • Make it thread-safe.
  • Add http client feature.
  • Add tcp server & client.
  • Support https.
  • Support udp.
  • Multi-platform support (Windows first).
  • Start logging thread when needed.

License

MIT license (© 2019 ATP)

evhttp's People

Contributors

atp798 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.