https://github.com/nilspolek/linkshortener
Link Shortener is a straightforward service designed for creating and managing shortened URLs using SQLite for data storage. Developed in Go, this application allows users to shorten long URLs, resolve shortened URLs back to their original destinations, and delete unwanted shortened links.
https://github.com/nilspolek/linkshortener
golang linkshortener microservice sqlite
Last synced: 5 months ago
JSON representation
Link Shortener is a straightforward service designed for creating and managing shortened URLs using SQLite for data storage. Developed in Go, this application allows users to shorten long URLs, resolve shortened URLs back to their original destinations, and delete unwanted shortened links.
- Host: GitHub
- URL: https://github.com/nilspolek/linkshortener
- Owner: nilspolek
- License: mit
- Created: 2024-09-10T17:48:53.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-11T15:49:56.000Z (almost 2 years ago)
- Last Synced: 2025-03-14T02:13:37.528Z (over 1 year ago)
- Topics: golang, linkshortener, microservice, sqlite
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Link Shortener
[](https://music.webnils.de/nilspolek/linkShortener)
Link Shortener is a simple service that uses SQLite for storing and managing shortened URLs. This Go-based application provides endpoints to shorten URLs and resolve them back to their original destination.
## Features
Shorten URLs: Convert long URLs into shorter, manageable links.
Resolve Shortened Links: Redirect shortened links to their original URLs.
Delete Shortened Links: Remove a shortened link and ensure it no longer redirects.
## Prerequisites
Go (Go 1.18 or later recommended)
## Start the application
```bash
git clone https://github.com/nilspolek/linkShortener.git
cd linkshortener
make run
```
## Usage
### Access a Link
```http
GET http://localhost:8080/
```
This request redirects to the original URL where short is the shortened link.
### Add a URL (POST request)
```json
{
"destination": "https://example.com"
}
```
returns
```json
{
"short": "shortened"
}
```
### Delete a shortened URL (DELETE request):
```json
{
"destination": "https://example.com"
"short": [", , ..."]
}
```
## Testing
The project includes tests to verify functionality. Run the tests with:
```bash
make test
```
The tests cover:
GET Request: Verify redirection from shortened link to the original URL.
POST and DELETE Requests: Test creating, resolving, and deleting shortened links.
Troubleshooting
Server Not Starting: Ensure no other services are running on port 8080.
Database Issues: Check logs for errors and ensure the database file has the correct permissions.
## Contributing
### To contribute to this project:
Fork the repository
Create a feature branch:
```bash
git checkout -b feature-branch
git commit -am 'Add new feature'
git push origin feature-branch
```
Open a Pull Request
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE)