Go user microservice with postgresql and docker
|- bin
|- cmd
|- core
|- pkg
|- config
|- controllers
|- models
|- routers
|- util
This folder contains the built-in go server.
This folder contains the core application(s). In this service, main.go in cmd/core is the main application.
The codes written for the service to work are located in this folder.
- config : The settings codes of the application are found here.
- controllers : Codes with all operations and logic are found here.
- models : The codes where database operations are made are coded here.
- routers : Here are the codes that define the routing of incoming requests.
- util : Tools coded for the application are stored in this folder.
To install, you must first authorize the service.sh file. Then type the install command.
sudo chmod +x ./service.sh
sudo ./service.sh install
The services must be built before running the application. Service building codes can be done easily with the service.sh file commands.
sudo ./service.sh build_db
sudo ./service.sh build
Starting database service
sudo ./service.sh run_db
Starting go microservice
sudo ./service.sh run
Below are all of the endpoints provided by the server, displayed by their relative URL, and the HTTP method with which you access them.
Example Request:
GET /api/user/ HTTP/1.1
Host: 192.168.1.2:8000
Example Request:
GET /api/user/232 HTTP/1.1
Host: 192.168.1.2:8000
Example Request:
POST /api/user/ HTTP/1.1
Host: 192.168.1.2:8000
Content-Type: application/json
{
"Name": "Kadir Umut",
"Email": "sanelkadir@gmail.com",
"Password": "secret"
}
Example Request:
DELETE /api/user/232 HTTP/1.1
Host: 192.168.1.2:8000
Example Request:
PUT /api/user/232 HTTP/1.1
Host: 192.168.1.2:8000
Content-Type: application/json
{
"Name": "Kadir Umut",
"Email": "sanelkadir@gmail.com",
"Password": "secret"
}
sudo ./service.sh stop_db