Skip to content

C REST Web Application - libuv, picohttpparser, libpq, parson

Notifications You must be signed in to change notification settings

stan-kondrat/c-rest-web-app

Repository files navigation

C REST Web Application

🚧 IN DEVELOPMENT 🚧

Overview

This project is being developed as a fun experiment in building a RESTful web application using C.

Features

  • 🚀 Fast (compare?)
  • lightweight (compare?)
  • Simple Router with middleware
  • PostgreSQL client
  • Asynchronous I/O with libuv
  • Feature-Based logging
  • Tests with cmocka
  • Benchmarks, Docker scratch image, gihub actions ..

Not Planned

The web server will NOT handle the following tasks (delegated to HAProxy/Traefik/Nginx):

  • SSL/TLS Termination
  • Static Content Serving and Caching
  • Traffic Compression (Gzip/Brotli)
  • Load Balancing
  • Rate Limiting

Dependencies

Installation

# MacOS
brew install libuv libpq cmocka  

# Ubuntu
apt install pkg-config libpq-dev libuv1-dev libcmocka-dev

# Windows Support?
# Most likely not, I don’t have a Windows machine, but technically it’s possible.

Submodules

# Initialize the submodules (if not done already)
git submodule update --init --recursive

Build and Run

make
make clean
make test
make run

Benchmarking

To benchmark the server, you can use tools like wrk and ab:

Install Tools

# MacOS
brew install wrk ab

Run Benchmark

wrk -t4 -c100 -d30s http://127.0.0.1:8080
ab -n 10000 -c 100 http://127.0.0.1:8080/

Developemnt

# Generate `compile_commands.json`
make .vscode/compile_commands.json

# Format code
make format

# Run tests in docker
make test-docker
make test-docker-linux-amd64
make test-docker-linux-arm64

Contributions

Feel free to give it a star, share your ideas, or open an issue! But please, no pull requests, as this is an educational project and will likely be archived once it's completed.

About

C REST Web Application - libuv, picohttpparser, libpq, parson

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published