GitHub - ecewo/ecewo: Asynchronous web framework for C, inspired by express.js

2 min read Original article ↗

Express-C Effect for Web Operations

A web framework for C — inspired by express.js

Table of Contents


Requirements

  • A C compiler (GCC or Clang)
  • CMake version 3.14 or higher

Quick Start

main.c:

#include "ecewo.h"
#include <stdio.h>

void hello_world(Req *req, Res *res) {
  send_text(res, OK, "Hello, World!");
}

int main(void) {
  if (server_init() != 0) {
    fprintf(stderr, "Failed to initialize server\n");
    return -1;
  }

  get("/", hello_world);

  if (server_listen(3000) != 0) {
    fprintf(stderr, "Failed to start server\n");
    return -1;
  }

  server_run();
  return 0;
}

CMakeLists.txt:

cmake_minimum_required(VERSION 3.14)
project(app VERSION 1.0.0 LANGUAGES C)

include(FetchContent)

FetchContent_Declare(
  ecewo
  GIT_REPOSITORY https://github.com/ecewo/ecewo.git
  GIT_TAG v3.6.1
)

FetchContent_MakeAvailable(ecewo)

add_executable(${PROJECT_NAME}
  main.c
)

target_link_libraries(${PROJECT_NAME} PRIVATE ecewo)

Build and Run:

mkdir build
cd build
cmake ..
cmake --build .
./app

Dependencies

No manual installation required for any of these dependencies.


Running Tests

mkdir build
cd build
cmake -DECEWO_BUILD_TESTS=ON ..
cmake --build .
ctest

Documentation

Refer to the docs for usage.


Plugins


Future Features

I'm not giving my word, but I'm planning to add these features in the future:

  • Rate limiter
  • WebSocket
  • TLS
  • SSE
  • HTTP/2
  • C++ and Nim bindings
  • Redis plugin

Example App

Here is an example blog app built with ecewo and PostgreSQL.


Contributing

Contributions are welcome. Please feel free to submit pull requests or open issues. See the CONTRIBUTING.md.


License

Licensed under MIT.