A URL Shortening service built in go using the go-gin framework and MongoDB as the database.
These instructions will get you a copy of the project up and running.
- Docker
- Clone the repo:
git clone https://github.com/mhope-2/url-shortner.git
- Rename
.env.sample
to.env
and update env variables accordingly
cp .env.sample .env
- Run with docker
docker-compose up
or
make up
go test -v -cover ./...
or
make test
- Endpoint:
/short-link
- Sample Requests
{
"url": "https://gobyexample.com/random-numbers",
"slug": "NTMyODk0"
}
{
"url": "https://gobyexample.com/random-numbers"
}
- Sample Response
{
"result": {
"shortened_url": "http://localhost:8085/NTMyODk0"
}
}
- MongoDB setup guide: https://www.mongodb.com/basics/create-database