Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nextrevision/shortly
shortly shortens urls by the seashore
https://github.com/nextrevision/shortly
Last synced: 19 days ago
JSON representation
shortly shortens urls by the seashore
- Host: GitHub
- URL: https://github.com/nextrevision/shortly
- Owner: nextrevision
- Created: 2022-03-10T00:25:38.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-03-10T19:28:28.000Z (over 2 years ago)
- Last Synced: 2023-04-04T06:18:02.934Z (over 1 year ago)
- Language: Go
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
shortly
=======`shortly` is a PoC url shortner written in go.
It is currently deployed on AWS and reachable at:
```
http://shortly-alb-952059741.us-east-1.elb.amazonaws.com
```## Getting Started
Requirements:
- docker
- docker-composeStart the server and local dependencies:
```shell
make local
```Issue a request against the endpoint:
```shell
make shorten-url
```Take the output of that command and browse to the location:
```shell
curl -vvv -L localhost:8000/{id}
```## Endpoints
| Path | Method | Description |
|--------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `/` | `GET` | Basic landing page demonstrating functionality. |
| `/` | `POST` | Shortens a supplied URL and returns a plain text "shortened" URL. Accepts `application/x-www-form-urlencoded` content with the `url` form key set to the URL you wish to shorten. |
| `/{id}` | `GET` | Resolves a shortened URL to it's intended destination and responds with a redirect to the location. |
| `/echo/{id}` | `GET` | Used to test the shorten and redirect workflows. It merely echos the `id` supplied. |
| `/-/metrics` | `GET` | Prometheus metrics scraping endpoint |
| `/-/health` | `GET` | Basic health check endpoint |## Test and Build
Tests can be run with:
```shell
make test
```and a Docker image can be built with:
```shell
make build
# optionally publish
# make publish
```## Deployment
This service can be deployed on AWS via Terraform. All terraform files are in the `terraform` directory and can be run with:
```shell
make tf-plan
make tf-apply
```### Architecture
There is a lot of boilerplate that needs to happen for new environments (vpc creation, gateways, etc) which will be
unnecessary for existing environments. The overall flow is outlined below:```
┌───────────────────────────────┐
│ │
│ ┌───────────────────┐ │
│ │ ECS Cluster │ │
│ │ ┌─────────────┐ │ │
│ │ │ Shortly │ │ │
┌────────────────────┐ │ │ │ │ │ │
│GET │ ┌──┴──┐ │ │ :8000 │ │ │
│ http://shortly/{id}├─────►│ ALB ├─┼──► │ │ │
└────────────────────┘ └──┬──┘ │ └┬────────┬───┘ │ │
│ │ │ │ │ │
│ └───┼────────┼──────┘ │
│ │ │ │
│ ┌──────▼───┐ ┌──▼──────────┐ │
│ │ Postgres │ │ Memcached │ │
│ │ (RDS) │ │(Elasticache)│ │
│ └──────────┘ └─────────────┘ │
│ │
└───────────────────────────────┘
```