Skip to content

Files

Latest commit

9f9f384 · Nov 29, 2024

History

History
26 lines (20 loc) · 682 Bytes

README.md

File metadata and controls

26 lines (20 loc) · 682 Bytes

HttpRouter

Simple & fast header-only router for HTTP servers.

  • Patterns with wildcards and parameters.
  • Functional handlers
  • Cross-platform
  • SIMD/zero-copy parsing
  • No memory allocations
    struct UserData {
        // pass whatever you need as user data
    } userData;

    HttpRouter<UserData *> r;

    r.add("GET", "/service/candy/:kind", [](UserData *user, auto &args) {
        std::cout << "Now serving candy of kind " << args[0] << std::endl;
    });

    r.add("GET", "/service/shutdown", [](UserData *user, auto &args) {
        std::cout << "Shutting down now" << std::endl;
    });

    r.route("GET", 3, "/service/candy/lollipop", 23, &userData);