AxlLind / libwebb

A small HTTP server framework in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libwebb

libwebb (webb is web in Swedish) is a small http server framework written in pure C99 with zero dependencies (for POSIX systems).

Usage

The basic usage of the library is as follows:

#include <string.h>
#include "webb/webb.h"

int http_handler(const WebbRequest *req, WebbResponse *res) {
  // implement behavior given the HTTP request...
  if (req->method != WEBB_GET)
    return 404;
  webb_set_body_static(res, "hello world", 11);
  webb_set_header(res, "content-type", strdup("text/raw"));
  return 200;
}

int main(void) {
  // do some setup...
  return webb_server_run("8080", http_handler);
}

For API documentation, see the library header file. The API is fully documented using doxygen comments.

See ./bin/webb.c for a small web server using the framework.

Compilation and installation

make build            # build the library
cp out/libwebb.a $DIR # copy the lib to your destination

# compile against the library and include the header path
gcc ... $DIR/libwebb.a -I$LIBWEBB_DIR/include

About

A small HTTP server framework in C

License:MIT License


Languages

Language:C 95.4%Language:Makefile 4.4%Language:Shell 0.2%