Small, and basic http server, written in full C 😾 🐕. With a 🍰 API, easy to use like a ⚽️.
Use the kevent for async socket. Available for OSX, or Free BSD.
#Installation
Use CMake to generate a Makefile, and the compile the source.
cmake .
make
#How to use
//Include the rocko public API
#include "rocko.h"
//Create a function which defines your route.
//Keep in mind the prototype has to be this one.
//You get the request informations in parameters with the body.
struct response welcome(struct request req) {
//Here you build your response.
//Following this schema :
//{response_code, body}
return (struct response){R_200, "Welcome !"};
}
int main(int argc, char **argv) {
//Initalise rocko server has to be call before everything
rocko_init();
//Add your routes here with your method, the request_uri, and your function
rocko_add_route("GET", "/welcome", welcome);
//Start and run the server with your port
rocko_start(8080);
return 0
}
###Todo 🦀💨
- A lot of tests
- Buffer cricular, for reading and write on the sockets
- Upload, download files
- Benchmark, with orther languages and frameworks