Skip to content

mnpk/asio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

asio

Simple http server framework based on boost::asio, using C++11

Build Status

Highlights

  • Easy to use
  • Header only
  • Boost::asio base
  • Modern C++ (using C++11)

Example

#include "server.hpp"
#include <string>

typedef std::shared_ptr<http::request> request_ptr;

int main() {
  http::server app;

  // simple text
  app.route["^/helloworld/?$"]["GET"] = [](request_ptr req) {
    return "<h1>Hello, world!</h1>";
  };

  // argument
  app.route["^/hello/((.*)+)/?$"]["GET"] = [](request_ptr req) {
    std::string name = req->path_match[1];
    return "Hello," + name + "!";
  };

  // json
  app.route["^/json/?$"]["GET"] = [](request_ptr req) {
    http::json j;
    j["message"] = "Hello, world!";
    return j;
  };

  app.port(9913)
     .threads(4)
     .run();

  return 0;
}

About

boost::asio based http server framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages