38-Moths

0.4

Minimal web-framework written in C.

GRESHUNKEL Documentation Source

What is it?

38-Moths is a web-server and a micro-framework designed to get you up and running with minimal dependencies.

See some of the examples for more.

#include <string.h>
#include <38-moths/38-moths.h>

static int
index_handler(const http_request *req, http_response *resp) {
	resp->out = malloc(strlen("Hello, World!");
	memcpy(resp->out, buf, strlen("Hello, World!"));

	resp->outsize = sizeof(buf);
	return 200;
}

int
main(int argc, char *argv[]) {
	int main_sock_fd = 0;

	static const route all_routes[] = {
		{"GET", "root_handler", "^/$", 0,
		 &index_handler, &heap_cleanup},
	};

	http_serve(&main_sock_fd, 2, all_routes, 1);
	return 0;
}