https://github.com/bartzalewski/url-shortener
This is a simple service to shorten URLs, track clicks, and provide basic analytics.
https://github.com/bartzalewski/url-shortener
go golang url-shortener
Last synced: 12 months ago
JSON representation
This is a simple service to shorten URLs, track clicks, and provide basic analytics.
- Host: GitHub
- URL: https://github.com/bartzalewski/url-shortener
- Owner: bartzalewski
- Created: 2024-05-27T18:17:52.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-27T18:18:10.000Z (about 2 years ago)
- Last Synced: 2025-06-22T01:42:48.853Z (12 months ago)
- Topics: go, golang, url-shortener
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# URL Shortener API
Welcome to the URL Shortener API! This is a simple service to shorten URLs, track clicks, and provide basic analytics.
## Features
- URL shortening
- Redirection to original URLs
- Click tracking and analytics
## Getting Started
Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes.
### Prerequisites
Ensure you have the following installed on your system:
- [Go](https://golang.org/doc/install) (version 1.16+)
- [Git](https://git-scm.com/)
### Installation
1. **Clone the repository**:
```sh
git clone https://github.com/bartzalewski/url-shortener.git
cd url-shortener
```
2. **Initialize Go modules**:
```sh
go mod tidy
```
3. **Run the application**:
```sh
go run main.go
```
The server will start on `http://localhost:8080`.
## API Endpoints
### URL Shortening
- **Shorten URL**
`POST /shorten`
Request:
```json
{
"url": "https://www.example.com"
}
```
Response:
```json
{
"short_url": "http://localhost:8080/abc123"
}
```
### URL Redirection
- **Redirect to Original URL**
`GET /{shortCode}`
Example:
`GET /abc123`
Redirects to `https://www.example.com`
### Analytics
- **Get Click Analytics**
`GET /analytics/{shortCode}`
Example:
`GET /analytics/abc123`
Response:
```json
{
"clicks": 10
}
```
## Built With
- [Go](https://golang.org/) - The Go programming language
- [Gorilla Mux](https://github.com/gorilla/mux) - A powerful URL router and dispatcher for Golang
## Contributing
Feel free to submit issues or pull requests. For major changes, please open an issue first to discuss what you would like to change.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Acknowledgments
- Thanks to the Go community for their invaluable resources and support.
- [Gorilla Mux](https://github.com/gorilla/mux) for making routing simple and efficient.
---
Happy coding! 🚀