A minimal RESTful API with in-memory database implemented via linked lists. Coded in C language using Unix websockets for networking and POSIX for multithreading.
docker
docker compose
docker compose up --build
make
gcc
make clean
make
A simple "User" model (models.h
) with fields "name" and "surname" is implemented in a in-memory database using linked lists. The first user starts with id = 0 and then is incremented when a new user is created. The user data in .json format can then be retrieved via its id.
The endpoints are defined in the routes.h
file. The default port is 8001.
GET /
- root with "Hello world" message
GET /users
- lists all users in .json format
GET /users/<id>
- list user data by its id
PUT /users/<id>
- update user data by its id
DELETE /users/<id>
delete user by its id
POST /users
- creates a new user
A simple Python file located in tests/tests.py
can be used to test each endpoint.
Contains the server settings. Currently, the only setting is ALLOWED_HOSTS, which contains an array of strings corresponding to the accepted client IP addresses.
Contains the database model. On this example, the model consists of a simple "user" table with fields "name" and "surname". Example of an user entry in .json format:
{"name": "Giga", "surname": "Chad"}
Contains all the accepted routes and a respective accepted HTTP methods.
Contains all functions related to the implementation of single linked lists in C, including creating a node, inserting, deleting, etc.
Integrates the requests from the HTTP methods to the linked list module, wrapping its functions and serving as a high level module.
The views related to each route and its respective HTTP methods.
This module contains functions that implement a multi-threaded server using Unix sockets.