GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - itsfuad/Xebec-Server: HTTP server implementation written in C++ using the Winsock API for Windows.

BranchesTags
Open more actions menu

Latest commit

 

History

17 Commits
17 Commits

Folders and files

NameName
Last commit message
Last commit date
.vscode
.vscode
 
 
examples
examples
 
 
include/xebec
include/xebec
 
 
src
src
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
main.cpp
main.cpp
 
 
run.bat
run.bat
 
 
test.bat
test.bat
 
 

Repository files navigation

Xebec-Server

A modern, header-only C++ HTTP server library with support for WebSockets, templates, and plugins.

Features

  • Header-only library
  • Modern C++ design
  • Cross-platform support (Windows and Unix-like systems)
  • HTTP/1.1 compliant
  • WebSocket support
  • Template engine
  • Plugin system
  • Middleware support
  • Static file serving
  • JSON responses
  • Error handling
  • Route parameters
  • Query string parsing

Requirements

  • C++17 or later
  • CMake 3.10 or later
  • Compiler with C++17 support

Installation

Using CMake

# Add to your CMakeLists.txt
add_subdirectory(xebec-server)
target_link_libraries(your_target PRIVATE xebec::xebec)

Manual Installation

  1. Clone the repository
  2. Copy the include/xebec directory to your project's include path
  3. Include the main header in your source files:
#include <xebec/xebec.hpp>

Quick Start

#include <xebec/xebec.hpp>
#include <iostream>

int main() {
    xebec::ServerConfig config;
    config.port = 8080;
    xebec::http_server server(config);
    
    // Set public directory for static files
    server.publicDir("public");
    
    // Add middleware for logging
    server.use([](xebec::Request& req, xebec::Response& res, xebec::MiddlewareContext::NextFunction next) {
        std::cout << "Request received" << std::endl;
        next();
    });
    
    // Add routes
    server.get("/", [](xebec::Request& req, xebec::Response& res) {
        res.html("index.html");
    });
    
    server.get("/api/hello", [](xebec::Request& req, xebec::Response& res) {
        res.json("{\"message\": \"Hello, World!\"}");
    });
    
    // Start server
    server.start();
    return 0;
}

Features in Detail

Route Parameters

server.get("/users/:id", [](xebec::Request& req, xebec::Response& res) {
    res << "User ID: " << req.params.at("id");
});

WebSocket Support

server.ws("/ws", [](xebec::WebSocketFrame& frame, std::function<void(const xebec::WebSocketFrame&)> send) {
    // Echo back the received message
    xebec::WebSocketFrame response;
    response.fin = true;
    response.opcode = 0x1; // Text frame
    response.payload = frame.payload;
    send(response);
});

Template Engine

server.set_template_dir("templates");
server.get("/", [](xebec::Request& req, xebec::Response& res) {
    std::map<std::string, std::string> vars = {
        {"title", "Welcome"},
        {"content", "Hello, World!"}
    };
    server.render(res, "index.html", vars);
});

Error Handling

server.use_error_handler([](const xebec::HttpError& e, xebec::Request& req, xebec::Response& res) {
    res.status_code(e.status_code())
       .json("{\"error\": \"" + std::string(e.what()) + "\"}");
});

Building from Source

git clone https://github.com/yourusername/xebec-server.git
cd xebec-server
mkdir build && cd build
cmake ..
cmake --build .

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

HTTP server implementation written in C++ using the Winsock API for Windows.

Topics

cppcpp-http-serverhttp-server

Resources

Readme
GPL-3.0 license
Activity

Stars

7 stars

Watchers

1 watching

Forks

0 forks
Report repository

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.