simple url shortener written in Go.
- Clone the repository.
git clone https://github.com/fidesy/go-url-shortener.git
cd go-url-shortener
- Rename .env.example to .env
cp .env.example .env
-
Select preferable database in ./configs/config.yaml field database options: postgres, mongo
-
Run app.
docker compose up -d
Sign up
curl -X POST -d '{"name": "John", "username": "john", "password": "john"}' http://localhost:8000/auth/sign-up
# {"id": 1}
Sign in and get authorization token
curl -X POST -d '{"username": "john", "password": "john"}' http://localhost:8000/auth/sign-in
# {"token": "YOUR_TOKEN"}
Create short URL
curl -X POST -H "Authorization: Bearer <YOUR_TOKEN>" -d '{"original_url": "https://vk.com"}' "http://localhost:8000/create"
# {"short_url": "http://localhost:8000/ti2SMt"}
Get original URL and Redirect
curl http://localhost:8000/ti2SMt
# <a href="https://vk.com">Temporary Redirect</a>.