Table of Contents
- Requirements
- Quick Start
- Dependencies
- Running Tests
- Documentation
- Plugins
- Future Features
- Example App
- Contributing
- License
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
- libuv for async event loop.
- llhttp for HTTP parsing.
- rax for radix-tree router.
- A customized arena allocator based on tsoding/arena.
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
ecewo-clusterfor multithreading.ecewo-cookiefor cookie management.ecewo-corsfor CORS impelentation.ecewo-fsfor file operations.ecewo-helmetfor automatically setting safety headers.ecewo-mockfor mocking requests.ecewo-postgresfor async PostgreSQL integration.ecewo-sessionfor session management.ecewo-staticfor static file serving.
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.