Simple URL shortener using Golang, PostgreSQL, Fiber and GORM
Rename .env.exmaple
to .env
Run database:
docker run --name goshort-db \
-e POSTGRES_USER=$DB_USERNAME -e POSTGRES_PASSWORD=$DB_PASSWORD \
-p $DB_PORT:$DB_PORT -d postgres:14
Run application:
In the root folder run go run main.go
or make run
GET /goshort
curl -i -H 'Accept: application/json' http://localhost:3000/goshort
GET /goshort/<id>
curl -i -H 'Accept: application/json' http://localhost:3000/goshort/1
POST /goshort
curl -i -H 'Content-Type: application/json' \
-d '{"goshort":"", "redirect":"http://github.com", "random":true}' \
-X POST http://localhost:3000/goshort
PATCH /goshort
curl -i -H 'Content-Type: application/json' \
-d ' {"id": 1, "redirect": "https://github.com", "goshort": "gh", "clicked": 0, "random": false}' \
-X PATCH http://localhost:3000/goshort
DELETE /goshort
curl -i -H 'Accept: application/json' -X DELETE http://localhost:3000/goshort/1
GET /r/<goshort>