Easily convert a long URL into short URL.
- create a short URL from a long URL
- redirect from a short URL to the original URL
- in-memory storage
- basic collision handling
- concurrent access protection with a mutex
- minimal home page
- the client sends a long URL to
POST /shorten - a unique short identifier is generated
- the mapping between the short URL and the long URL is stored in memory
- when
GET /<id>is called, the client is redirected to the original URL GET /serves a minimal home page
By default, the server runs on: http://localhost:8081
You can configure the base URL with the SITEURL environment variable
export SITEURL=your_own_site_with_httpclone the repository, then start the server:
go run main.goIn another terminal window, create a short URL from a long one
curl -X POST -d "url=http://example.com/some_very_long_url" http://localhost:8081/shortenResponse
http://localhost:8081/short_url- in-memory storage only
- data is lost when the server stops