Hello from CEB

A simple web server in the C3 language

A lightweight http server framework written in C3 powered by c3io and libuv, inspired by Hono, Elysia and express.js .

Features

Low-Level Bindings

Dependencies

Installing libuv

Arch Linux:

sudo pacman -S libuv

Ubuntu/Debian:

sudo apt install libuv1-dev

macOS:

brew install libuv

Fedora:

sudo dnf install libuv-devel

Testing

c3c test

The test suite includes 30 tests covering all async modules.

Usage

As a Git Submodule

Add ceb as a submodule to your project:

git submodule add https://github.com/shishantbiswas/ceb.git lib/ceb.c3l
git submodule update --init --recursive

# for updating
# git submodule update --remote --recursive

Then add it to your project.json file like so:

  // existing config

  "dependency-search-paths": [
    "lib"
  ],
  "dependencies": [
    "ceb" // emit the extension
  ]

  // existing config

Minimal Example

module main;
import std::io;
import ceb;

fn int main() {
  Server server;
  server.init();

  defer server.start();

  server
    .get("/heyo",
      fn (
        Request req
      ) => {
        .status = 200,
        .status_text = StatusText.OK,
        .data = dstring::temp("Hello World"),
        .content_type = ContentType.TXT
      }
    )

  io::printf("Server starting...\n");  
  return 0;
}

Building

c3c build

This will create build/main in the build directory. Which is the server executable and can be deployed on most linux system and docker based platforms.

Project Structure

src
  ├── ceb.c3
  ├── ceb_handlers.c3     // provider hono like interface like `server.get` and `server.use`
  ├── chunked.c3          // for chunked data used for streaming
  ├── enums.c3            // contains enums like (ContentType)
  ├── examples            // examples directory 
  ├── headers.c3          // internal parser util for header
  ├── middleware.c3       // contains middleware code
  ├── parser.c3           // code for header parser 
  ├── router.c3           // tree based router similar to linear router from hono
  ├── utils.c3            // contains utilities, general purpose function
  └── version.c3          // http versioning function
  

Current Limitations

Development Status

This project is in active development and should be considered alpha software. It is primarily intended for:

Do not use this in production environments.