Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eyenx/gursht
A simple URL shortener written in Go
https://github.com/eyenx/gursht
Last synced: 10 days ago
JSON representation
A simple URL shortener written in Go
- Host: GitHub
- URL: https://github.com/eyenx/gursht
- Owner: eyenx
- License: agpl-3.0
- Created: 2021-03-20T17:16:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T13:04:56.000Z (8 months ago)
- Last Synced: 2024-06-21T08:23:39.546Z (5 months ago)
- Language: Go
- Size: 59.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gursht - a simple URL shortener written in GO
[![Lint and Test](https://github.com/eyenx/gursht/actions/workflows/lint-and-test.yaml/badge.svg)](https://github.com/eyenx/gursht/actions/workflows/lint-and-test.yaml)
[![Release](https://github.com/eyenx/gursht/actions/workflows/release.yaml/badge.svg)](https://github.com/eyenx/gursht/actions/workflows/release.yaml)
[![QA](https://github.com/eyenx/gursht/actions/workflows/qa.yaml/badge.svg)](https://github.com/eyenx/gursht/actions/workflows/qa.yaml)**Still a WIP**
I always wanted to write something in Golang, and this is my first real mini project trying it out.
My main motivation behind this was getting a url shortener for my mutt configuration. [z3bra](http://z3bra.org) uses a url shortener too, and I wanted to implement this too. The main idea behind it, is getting rid of mutt's `+` line wraps when a link gets too long for the term.
Find a demo of the app running on https://s.uff.li. Feel free to use it.
## Getting started
### build & run it manually
```
git clone https://github.com/eyenx/gursht && cd gursht
go build
./gursht
```### Docker
You can use it directly with the provided `deploy/docker-compose.yml` or with this oneliner:
#### In memory state
```
docker run -n gursht -p 3000:3000 ghc.rio/eyenx/gursht:latest
```#### Example with Redis
```
docker run -n gursht_redis -d redis
docker run -p 3000:3000 -e REDIS_ENABLED=true -e REDIS_HOST=gursht_redis ghcr.io/eyenx/gursht:latest
```Access http://localhost:3000 and read the howto.
### Kubernetes
tbd
### Helm
tbd
## Usage
a simple request looks like this:
```
curl -d '{"LongUrl":"https://example.com/my/very/long/url"}' localhost:3000 -H "Content-Type: application/json"
{"LongUrl":"https://example.com/my/very/long/url","ShortUrl":"http://localhost/2eCRU"}%
```This will save the created short url by mapping it with the long url as value.
Now, accessing your host with the newly created short url, will redirect you to the long one:
```
curl http://localhost:3000/2eCRU
Moved Permanently.
```## Additional configuration
configuration is done by setting environment variables:
```
REDIS_ENABLED # set to true if you wanna use REDIS, default is inmemory go map
REDIS_PORT # set the redis port to use
REDIS_HOST # set the redis host to use
SHORTURL_HOST # set the external short url hostname
SHORTURL_LENGTH # set the length of the created random short path (default: 5)
```## TODO
* Make it possible to provide the short url on request
* Already saved longurl shouldn't be mapped to a new shorturl (might not work with redis as backend)
* index.html should provide a Getting started
* `deploy/` folder providing docker-compose & kubernetes Yaml files
* Helm Chart?