REXON is a lightweight, cross-platform C++ backend library designed to handle basic HTTP routing for both Windows and Linux. It provides a simple, modern API for creating backend applications with support for GET and POST requests, custom 404 handlers, and optional logging.
- 🖥️ Cross-platform: Works on both Windows and Linux
- 🔌 Built-in HTTP server
- 🧭 Route handling for
GETandPOST - 📜 Simple response customization (status, content-type, body)
- 🛠️ Custom 404 (Not Found) handler
- 🧩 Utility to extract URL query attributes
- 🪵 Optional request logging
- 🔓 MIT Licensed
Include the REXON.h file in your C++ project:
#include "REXON.h"#include "REXON.h"
int main() {
REXON::api server(8080);
server.GET("/", [](std::string) {
return REXON::Response("200 OK", "text/plain", "Welcome to REXON!");
});
server.POST("/data", [](std::string body) {
return REXON::Response("200 OK", "application/json", "{\"received\":\"" + body + "\"}");
});
server.NOTFOUND([](std::string) {
return REXON::Response("404 Not Found", "text/plain", "This route does not exist.");
});
server.show_log(true);
server.start();
return 0;
}| Method | Description |
|---|---|
api(int port) |
Create server listening on specified port |
start() |
Start the server |
stop() |
Stop the server |
GET(path, callback) |
Register a GET route with a callback |
POST(path, callback) |
Register a POST route with a callback |
NOTFOUND(callback) |
Handle undefined routes |
show_log(bool) |
Enable/disable logging of client connections |
| Method | Description |
|---|---|
set_status() |
Set HTTP status code (e.g. "200 OK") |
set_content_type() |
Set MIME type (e.g. "text/plain") |
set_body() |
Set the response body |
get_status() |
Get the status |
get_content_type() |
Get the content type |
get_body() |
Get the response body |
std::string REXON::get_attribute(std::string query, std::string key);Extract a value from a query string (e.g. ?id=123&name=John → key: "id" → "123").
- On Windows, REXON uses Winsock (requires linking with
ws2_32.lib) - On Linux, it uses standard POSIX sockets
Platform-specific details are handled automatically by the library.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Feel free to submit pull requests or report issues.
Made with ❤️ in C++ by 7sn
GitHub: @7sndev
Repo: 7sndev/rexon