Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niklasmerz/gistdirect
Redirect to urls from a gist with a hostfile. Ready for serverless and Containers
https://github.com/niklasmerz/gistdirect
gist github-gist golang redirect serverless url-shortener
Last synced: 2 days ago
JSON representation
Redirect to urls from a gist with a hostfile. Ready for serverless and Containers
- Host: GitHub
- URL: https://github.com/niklasmerz/gistdirect
- Owner: NiklasMerz
- License: mit
- Created: 2019-02-14T21:08:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-30T20:52:01.000Z (over 1 year ago)
- Last Synced: 2024-06-21T04:28:53.085Z (3 months ago)
- Topics: gist, github-gist, golang, redirect, serverless, url-shortener
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gistdirect
## Gistdirect is a simple URL redirection service / URL shortener.
> Imagine bitly.com or goo.gl and your hosts file combined
[![Run on Google Cloud](https://storage.googleapis.com/cloudrun/button.svg)](https://console.cloud.google.com/cloudshell/editor?shellonly=true&cloudshell_image=gcr.io/cloudrun/button&cloudshell_git_repo=https://github.com/niklasmerz/gistdirect)
Create a Github Gist or just any plain file hosted somewhere. Gistdirect will grap that file and redirect the alias to the full url.
Sample "host" file:
```
gh https://github.com
```[Test File](https://gist.github.com/NiklasMerz/a9b5905f742b5863197a0af0465a39f6)
**The URL to the file is provided as an environment variable**: `GIST_URL`. Make sure to provide an URL that is a raw textfile. If you use a GitHub Gist click on the raw button before grabbing the URL like `https://gist.githubusercontent.com/NiklasMerz/a9b5905f742b5863197a0af0465a39f6/raw/`.
It is a simple Go function which is easy to run on any serverless platform. You can also run the binary somewhere and it will listen on port 8080. Executables are avaible from [releases](https://github.com/NiklasMerz/gistdirect/releases).
I got it running with Google Cloud Functions and Firebase hosting. You can deploy the function from "function.go" via the web interface or gcloud CLI. Firebase can be used to assign a [custom domain](https://firebase.google.com/docs/hosting/custom-domain) to the function. Firebase CLI and the "firebase.json" file help you to assing the function to the root of the domain.
## Using the Dockerfile
Gistdirect is on Docker Hub so you can just run:
```
docker run -p 8080:8080 -e GIST_URL='https://gist.github.com/NiklasMerz/a9b5905f742b5863197a0af0465a39f6/raw/' niklasmerz/gistdirect
```