Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/red-life/shorten-it
Go-based scalable URL shortening service
https://github.com/red-life/shorten-it
golang url-shortener
Last synced: 20 days ago
JSON representation
Go-based scalable URL shortening service
- Host: GitHub
- URL: https://github.com/red-life/shorten-it
- Owner: red-life
- License: mit
- Created: 2023-10-21T13:54:35.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-11T22:08:48.000Z (about 1 year ago)
- Last Synced: 2024-06-21T15:43:23.953Z (6 months ago)
- Topics: golang, url-shortener
- Language: Go
- Homepage:
- Size: 66.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shorten It
This is a REST API for shortening long URLs, written in Go. It features an in-memory cache for improved performance.## Features
- REST API for shortening URLs
- In-memory cache to avoid hitting the data store frequently
- Postgres for persistence at the datastore layer
- Using a key generate service instead of random key generation
- Proper error handling
- Request validating
- Fully dockerized for easy deployment## Design & Architecture
- Hexagonal Architecture
- Separation of Concerns Principle
- Decorator Pattern
- Repository Pattern## Endpoints
### Shorten a URL
**Request:**
```bash
curl --header "Content-Type: application/json" \
--request POST \
--data '{"url": "htps://google.com"}' \
http://localhost:5000/shorten
```
**Response:**
```json
{"key": "xyz"}
```### Redirect to the original URL
**Request:**
```bash
curl http://localhost:5000/xyz
```
**Response:**
```
Returns 302 Found with a Location header to the original URL.
```## Deployment
### Prerequisites
- Docker & Docker Compose
- Make
### Steps
- Copy .env.sample and change it on your own \
`cp .env.sample .env`
- Build the custom image and run the containers \
`make run`
- It will be available at `http://localhost:${PORT}`
## Run Tests
### Prerequisites
- Make
### Steps
- Just run the command below to run all the available tests \
`make run_tests`## Next Steps
- [ ] Document the API using Swagger
- [ ] Add Logging