A REST API template with a load balancer.
# Download this project
go get github.com/ashish493/go-to-rest
cd go-to-rest
sudo /etc/init.d/nginx start
# build and run the RESTful API server
make build
make run
#run the load balancer from it's conf file
cp /nginx/nginx.conf /etc/nginx/nginx.conf
sudo systemctl start nginx
Before running the server make sure to change the values in the config.json file according to your uses or else leave it to it's default values. You can also load these values from a ENV file, jus change the file name in the config.go
You can build the image manually from the Dockerfile or you can directly pull the image by following steps:-
# pull the latest build of the image
docker pull ashishmalik47/go-to-rest:latest
# Running the container
docker run -d -p 5000:5000 go-to-rest
GET
: Get all projectsPOST
: Create a new project
GET
: Get a projectPUT
: Update a projectDELETE
: Delete a project
PUT
: Archive a projectDELETE
: Restore a project
GET
: Get all tasks of a projectPOST
: Create a new task in a project
GET
: Get a task of a projectPUT
: Update a task of a projectDELETE
: Delete a task of a project
PUT
: Complete a task of a projectDELETE
: Undo a task of a project
The API endpoint is http://localhost:5000.
Try the URL http://localhost:5000/projects
in a browser to get a response of all listed projects.
If you have cURL
or some API client tools (e.g. Postman), you may try the following :-
curl -v http://localhost:5000/projects
curl -d 'title=todo' http://localhost:5000/projects/{title}
curl -X DELETE http://localhost:5000/projects/{todo}