38-Moths

 

A C micro web-framework.

The most webscale™ way to throw 502's since your last CGI project.

#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;
}
					

It's just C. Write what you want, use your tools.

A custom templating engine called GRESHUNKEL.

  • Xbox Live® syntax
  • Loops
  • Interpolate strings!
<!DOCTYPE html>
<html>
    <body>
        <h1>Hello from GRESHUNKEL!</h1>
        <p>Current server uptime is: xXx @UPTIME xXx</p>
    </body>
</html>