URL Shortener is a simple web service that allows you to shorten long URLs into shorter and more convenient ones.
This service is written in Go programming language and uses SQLite database to store shortened URL addresses.
To install and run the service, you will need Docker installed. Follow these steps:
-
Clone the repository:
git clone https://github.com/your-username/url-shortener.git
-
Navigate to the project directory:
cd url-shortener
-
Build the Docker image:
docker build -t my-url-shortener .
- Run the Docker container:
docker run -p 8080:8080 -e BASE_URL=https://s.inxo.ru -v $(pwd)/database.db:/app/database.db my-url-shortener
Now your URL Shortener is up and running and accessible at http://localhost:8080
.
To shorten a long URL, send a POST request to /shorten
with a url
parameter containing your long URL. For example:
curl -X POST -d "url=https://example.com/very/long/url" http://localhost:8080/shorten
The service will return the shortened URL in the response.
To use the shortened URL, simply navigate to it in your browser or make a GET request to it.
To configure the base URL, modify the BASE_URL
environment variable in the Dockerfile.
Author: Dima Lario