Skip to content

Commit 7bc414d

Browse files
authored
Merge pull request #26 from BennyFranciscus/add-ulfius
Add Ulfius: C REST framework on GNU Libmicrohttpd (first C app framework!)
2 parents 9ec8595 + dba116a commit 7bc414d

4 files changed

Lines changed: 524 additions & 0 deletions

File tree

frameworks/ulfius/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM ubuntu:24.04 AS build
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
gcc make cmake git ca-certificates pkg-config \
5+
libmicrohttpd-dev libjansson-dev libcurl4-openssl-dev \
6+
libgnutls28-dev libsqlite3-dev zlib1g-dev \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
# Build ulfius and its dependency orcania/yder from source
10+
WORKDIR /tmp
11+
RUN git clone --depth 1 --branch v2.3.3 https://github.com/babelouest/orcania.git && \
12+
cd orcania && cmake -B build -DCMAKE_BUILD_TYPE=Release -S . && \
13+
cmake --build build -j$(nproc) && cmake --install build
14+
15+
RUN git clone --depth 1 --branch v1.4.20 https://github.com/babelouest/yder.git && \
16+
cd yder && cmake -B build -DCMAKE_BUILD_TYPE=Release -DWITH_JOURNALD=OFF -S . && \
17+
cmake --build build -j$(nproc) && cmake --install build
18+
19+
RUN git clone --depth 1 --branch v2.7.15 https://github.com/babelouest/ulfius.git && \
20+
cd ulfius && cmake -B build -DCMAKE_BUILD_TYPE=Release \
21+
-DWITH_WEBSOCKET=OFF -DWITH_CURL=OFF \
22+
-DCMAKE_C_FLAGS="-O3 -flto" \
23+
-S . && \
24+
cmake --build build -j$(nproc) && cmake --install build
25+
26+
RUN ldconfig
27+
28+
# Build our server
29+
WORKDIR /app
30+
COPY src/server.c ./
31+
RUN gcc -O3 -flto -march=native -o server server.c \
32+
$(pkg-config --cflags --libs libulfius) \
33+
-ljansson -lsqlite3 -lz -lm -lpthread
34+
35+
FROM ubuntu:24.04
36+
RUN apt-get update && apt-get install -y --no-install-recommends \
37+
libmicrohttpd12t64 libjansson4 libgnutls30t64 libsqlite3-0 zlib1g && \
38+
rm -rf /var/lib/apt/lists/*
39+
COPY --from=build /usr/local/lib/libulfius.so* /usr/local/lib/
40+
COPY --from=build /usr/local/lib/liborcania.so* /usr/local/lib/
41+
COPY --from=build /usr/local/lib/libyder.so* /usr/local/lib/
42+
COPY --from=build /app/server /server
43+
RUN ldconfig
44+
45+
EXPOSE 8080 8443
46+
CMD ["/server"]

frameworks/ulfius/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Ulfius — C REST Framework
2+
3+
[Ulfius](https://github.com/babelouest/ulfius) is a lightweight HTTP framework for building REST APIs in pure C. Built on GNU Libmicrohttpd with Jansson for JSON processing, it's designed for embedded systems and applications where a small memory footprint matters.
4+
5+
## Why it's interesting
6+
7+
- **Pure C** — first C application framework in HttpArena (h2o/nginx are web servers, not app frameworks)
8+
- **Libmicrohttpd backend** — battle-tested GNU HTTP library under the hood
9+
- **Minimal footprint** — designed for embedded/constrained environments
10+
- **Solo developer project**@babelouest has been maintaining this since 2015
11+
12+
## Implementation notes
13+
14+
- Uses Jansson for all JSON serialization (same lib used by many C projects)
15+
- Thread-local SQLite connections with prepared statements for `/db`
16+
- Pre-loads datasets and static files into memory at startup
17+
- TLS via GnuTLS (Ulfius's built-in secure framework support)
18+
- Signal-based clean shutdown

frameworks/ulfius/meta.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"display_name": "ulfius",
3+
"language": "C",
4+
"type": "framework",
5+
"engine": "libmicrohttpd",
6+
"description": "Ulfius C REST framework built on GNU Libmicrohttpd with Jansson JSON. Lightweight with small memory footprint, designed for embedded systems.",
7+
"repo": "https://github.com/babelouest/ulfius",
8+
"enabled": true,
9+
"tests": [
10+
"baseline",
11+
"noisy",
12+
"pipelined",
13+
"limited-conn",
14+
"json",
15+
"upload",
16+
"compression",
17+
"mixed"
18+
]
19+
}

0 commit comments

Comments
 (0)