This repository contains a simple golang-API to manage CRUD operations on users and their friends.
To use the API, follow these instructions: Clone the repository into your desired local directory
git clone https://github.com/tommywiffler/golang-api.git
Navigate to the project directory and run the following commands to clean up any dependencies
go mod tidy
go mod vendor
Run the API server
go run main.go
The API endpoints are exposed at the following URI
http://127.0.0.1:8080/api/
POST /users
{
"id": 3333,
"name": "Todd",
"email": "todd@email.com",
"age": 45,
"friends": [
1234, 1212
]
}
GET /users
GET /users/{id}
PATCH /users/{id}
{
"name": "Dodd",
"email": "dodd@email.com",
"age": 46
}
DELETE /users/{id}
GET /users/{id}/friends
POST /users/{id}/friends
{
"id": 5678
}
DELETE /users/{id}/friends/{id}
There is a Postman Collection of example requests included in the repository that can be imported to a Postman environment and used for testing.