+
Skip to content

savashn/ecewo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Express-C Effect for Web Operations

Inspired by Express.js. It’s minimalist, unopinionated, and easy-to-use (in a C kind of way).

Table of Contents

Requirements

  • A C compiler
  • 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, 200, "Hello, World!");
}

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

    get("/", hello_world);

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

    server_run();
    return 0;
}

CMakeLists.txt:

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

include(FetchContent)

FetchContent_Declare(
    ecewo
    GIT_REPOSITORY https://github.com/savashn/ecewo.git
    GIT_TAG v2.0.0
)

FetchContent_MakeAvailable(ecewo)

add_executable(${PROJECT_NAME}
    main.c
)

target_link_libraries(${PROJECT_NAME} PRIVATE ecewo)

Build:

mkdir build && cd build && cmake .. && cmake --build .

Benchmarks

Here are 'Hello World' benchmark results for several frameworks compared to Ecewo. See the source code of the benchmark test.

Lower is better.

Framework Average Median Max P90 P95
Ecewo 0.387ms 0.152ms 7.23ms 0.99ms 1.09ms
Axum 0.442ms 0.505ms 5.61ms 1.01ms 1.21ms
Go 0.958ms 0.725ms 12.62ms 1.97ms 2.48ms
Express.js 1.85ms 1.58ms 11.05ms 3.48ms 4.27ms

Documentation

Refer to the docs for usage.

Ecosystem

Example App

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

Contributing

Contributions are welcome. Please feel free to submit a pull requests or open issues for feature requests or bugs.

License

Licensed under MIT.

About

Minimalist web framework for C

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载