# Get the code
git clone https://github.com/suvidsahay/GoRestAPI Factly
cd Factly
Assuming that Postgres(v12 or later) is installed:
- Create role:
sudo -u postgres createuser -P factly # prompts for password
- Create database:
sudo -u postgres createdb -O factly factly
Create .env file based in sample.env and change the password provided while creating the factly user
The web server can be started as shown below(assuming Go 1.13 is installed. By default it listens for
HTTP connections on port 5000, so point your client at
localhost:5000
.
go run main.go
- GET /users
curl -XGET localhost:5000/users
- POST /user
curl -XPOST -d '{"name":"Something"}' -H 'Content-Type: application/json' localhost:5000/user
- PUT /user/{id}
curl -XPUT -d '{"name":"New Name"}' -H 'Content-Type: application/json' localhost:5000/user/1
- DELETE /user/{id}
curl -XDELETE localhost:5000/user/1
Run the following to command to test your application
go test -v