Code Monkey home page Code Monkey logo

netflex's Introduction

NetFlex Build Status

NetFlex is a modern C++11 HTTP Server.

Requirement

NetFlex has no dependency. Its only requirement is C++11.

This library is still under development

Example

//! netflex server
netflex::http::server server;

//! routes
//! /:var_name provides you a way to define URLs including variables
server.add_route({netflex::http::method::GET, "/users/:user_name/articles/:post_id",
  [](const netflex::http::request& request, netflex::http::response& response) {
    __NETFLEX_LOG(info, "/users/:user_name/articles/:post_id callback triggered");
    __NETFLEX_LOG(info, "Headers: " + netflex::misc::printable_header_list(request.get_headers()));
    __NETFLEX_LOG(info, "Params: " + netflex::misc::printable_params_list(request.get_params()));

    response.set_body("What's up?!\n");
    response.add_header({"Content-Length", "12"});
  }});

//! optional middlewares
server.add_middleware([](netflex::routing::middleware_chain& chain, netflex::http::request& request, netflex::http::response& response) {
  //! alter request
  request.add_header({"MiddleWare-Custom-Header", "MiddleWare custom header value"});

  //! proceed
  chain.proceed();

  //! alter response
  response.set_body(response.get_body() + "Powered by Netflex\n");
  response.add_header({"Content-Length", response.get_body().length()});
});

//! run server
server.start("0.0.0.0", 3001);

Wiki

A Wiki is available and provides full documentation for the library as well as installation explanations.

Doxygen

A Doxygen documentation is available and provides full API documentation for the library.

Motivations and goals

Serving HTTP requests from a C++ software might seem unconventional, but some projects do require it (and I personally already encounter such need).

However, even though C++ is getting older with a more and more complete standard library and a huge active community, tools for this kind of tasks are very limited. A few solutions exist down the road, hopefully, including cpp-netlib which is the main and maybe only usable C++ library providing HTTP server & client features.

However, cpp-netlib could be lot better. Its design is pretty old, the documentation is a real mess and the resulting library is not stable enough.

NetFlex aims to provide an alternative to cpp-netlib and other smaller C++ HTTP libraries with a modern C++ design. One of its goal is to be as much flexible as possible in order for the users to integrate it easily in their existing program while providing the core features to fulfill HTTP support.

NetFlex will be compliant with the following HTTP RFC:

That is, NetFlex aims to be HTTP/1.1 RFC compliant. Support will be first provided for HTTP, then HTTPS in a second time and lastly HTTP/2.0.

License

NetFlex is under MIT License.

Contributing

Please refer to CONTRIBUTING.md.

Author

Simon Ninon

netflex's People

Contributors

cylix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netflex's Issues

threading model, handle async request

Hi! Thanks for this, I like the code base so far, so clean! Nice.

If it is possible, could you tell us your view on how you will approach "async request handling" inside NetFlex?

Thanks!

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.