Skip to content

campos-sergio/rest_api_c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rest_api_c

A simple REST API in C using microhttpd lib docker-compose and PostgreSQL.

Setup

Requires Docker and Docker Compose.

# First: configure credentials
cp .env.sample .env
# Edit .env and set your database name, user, and password

# Second: create the database and table
make dbinit

# Build and start the server
make run

The API will be available at http://localhost:8888.

CRUD Operations

# Health check
make healthcheck

# List all users
make listusers

# Get user by ID
make getuserbyid id=1

# Create a user
make createuser name="John Doe" email="john@example.com"

# Update a user
make updateuser id=1 name="Jane Doe" email="jane@example.com"

# Delete a user
make deleteuser id=1

Other Commands

make stop   # Stop containers
make logs   # Follow container logs

About

A REST API demo in C using microhttpd lib and PostgreSQL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors