This documentation provides information about the project and its components.
To install and run the project, follow these steps:
- Clone the repository:
git clone github.com/tz3/go-simple - Change to the project directory:
cd go-simple - Install dependencies:
go mod download - Change your sql connection url
- Start the project:
expoexport DB_CONNECTION_STRING={{YOUR_CONNECTION_STRING}} go run cmd/main.go
Once the project is running, you can access it at http://localhost:8080. Use the provided APIs to interact with the application.
To run the project using Docker Compose, make sure you have Docker and Docker Compose installed on your machine. Then, follow these steps:
- Build the Docker image:
docker-compose build - Start the project using
Docker Compose: docker-compose up - To Use end points with default port example:-
GET http://localhost:8080/users?userID=1
The project uses environment variables for configuration. The following variables can be set:
DB_CONNECTION_STRING: Connection string for the PostgreSQL database.
The project exposes the following API endpoints:
GET /users?userID=1: Get a user by ID.POST /users: Create a new user.
To create a new user, make a POST request to /users with the following JSON body:
{
"firstName": "Moutaz",
"lastName": "Chaara"
}