A simple URL shortener written in Go.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Things you need on your machine.
- Go
- Any text editor or IDE
Clone the repository to your local machine.
git clone https://github.com/timpratim/url-shortener.git
cd url-shortener
go build
go run main.go
- Shortening a URL To shorten a URL, make a POST request to http://localhost:8080/shorten with a JSON payload containing the original URL:
curl -X POST -d "url=https://twitter.com/BhosalePratim" http://localhost:8080/shorten
- The response will be a JSON object containing the short URL:
{"short_url":"http://localhost:8080/abc123"}
To redirect to the original URL, make a GET request to the short URL:
This will redirect you to the original URL.
Go - The programming language.
Pratim Bhosale