A URL minifier REST API written in Go, with Gin framework
APP_MODE=development | production
PORT=4000
DATABASE_URI=<your mongodb uri>
DATABASE_NAME=<your mongodb collection name>
JWT_ISSUER=
JWT_SECRET=
EMAIL_VERIFICATION_TOKEN_SECRET=
HASH_COST=10
larger HASH_COST will result in slower but more secure hashing
- Clone the repo and run
go get
to install all the dependencies. - Create a
.env
file at the root of the project and add the above mentioned variables. - Run
go run .
to start the project indebug
mode. It is a good idea to setAPP_MODE=development
. - Request the following endpoints from either your own UI or Postman.
Common prefix –
/api
Common prefix –
/auth
- Get link
- Set new password
Common prefix –
/minify
Request
curl --location --request GET 'http://localhost:4000/api/minify'
Response
[
{
"_id": "6598609d7d1a137466f0f8eb",
"label": "Official Go Website",
"active": true
}
]
Request
Payload
{
"link": "https://go.dev",
"label": "Official Go Website"
}
curl --location --request POST 'http://localhost:4000/api/minify' \
--header 'Content-Type: application/json' \
--data '{
"link": "https://go.dev",
"label": "Official Go Website"
}'
Sending a request to this endpoint will redirect to the original url that was minified.
curl --location --request GET 'http://localhost:4000/api/minify/65985472c4fd59a24436a281'