Skip to content

⛽ Lightweight embeddable HTTP server. Written in C++11 (or C++03 w/boost).

License

Notifications You must be signed in to change notification settings

r-lyeh-archived/route66

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

route66

  • Route66 is a lightweight embeddable HTTP server. Written in C++11 (or C++03 w/boost).
  • Route66 is handy. Support for CRUD, MIME and wildcard routing.
  • Route66 is tiny. One header and one source file.
  • Route66 is cross-platform.
  • Route66 is zlib/libpng licensed.

API

take a look into route66.hpp header

Debugging

  • Tweak R66LOG environment variable to filter and display any incoming http request in runtime.
  • Requests matching wildcard patterns will be printed. Ie, */*.html*, *POST /form?*, *192.168.*, etc...

sample

#include <cassert>
#include <iostream>
#include "route66.hpp"

int main() {
    // create index route service
    assert(
        route66::create(8080, "GET /",
            []( route66::request &request, std::ostream &headers, std::ostream &contents ) {
                headers << route66::mime(".html");
                contents << "<html><body><a href='/hello'>#</a></body></html>";
                return 200;
            } )
    );

    // create hello world route service
    assert(
        route66::create(8080, "GET /hello*",
            []( route66::request &request, std::ostream &headers, std::ostream &contents ) {
                headers << route66::mime(".text");
                contents << "hello world!";
                return 200;
            } )
    );

    // create echo route service
    assert(
        route66::create(8080, "GET /echo*",
            []( route66::request &request, std::ostream &headers, std::ostream &contents ) {
                headers << route66::mime(".text");
                contents << request.url;
                return 200;
            } )
    );

    // do whatever in your app. notice that you could change any route behavior in runtime.
    std::cout << "server ready at localhost:8080 GET(/, /hello*, /echo*)" << std::endl;
    for( char ch ; std::cin >> ch ; )
    {}
}

About

⛽ Lightweight embeddable HTTP server. Written in C++11 (or C++03 w/boost).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages