Shortly is a simple URL shortener service written in Golang. More detailed step by step tutorial can be found here.
Our URL shortening system should meet the following requirements:
- Given a URL, our service should generate a shorter and unique alias of it. This is called a short link.
- When users access a short link, our service should redirect them to the original link.
- Users should optionally be able to pick a custom short link for their URL.
- Links will expire after a standard default timespan. Users should be able to specify the expiration time.
- The system should be highly available.
- URL redirection should happen in real-time with minimal latency.
- Shortened links should not be guessable.
go run cmd/main.go
Generate a short URL
curl 'http://localhost:8080/' -H 'Content-Type: application/x-www-form-urlencoded' --data 'link=https://google.com'
Redirect
curl http://localhost:8080/l/3E84B09B18848F91
Visitor Count
curl http://localhost:8080/s/3E84B09B18848F91