Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kashav/go-url-shortener

Shorten URLs with GitHub repositories and the http-equiv attribute.
https://github.com/kashav/go-url-shortener

golang http-equiv refresh url-shortener

Last synced: 6 days ago
JSON representation

Shorten URLs with GitHub repositories and the http-equiv attribute.

Awesome Lists containing this project

README

        

# go-url-shortener

A simple URL shortener that uses GitHub as a backend. This uses the [`http-equiv` refresh attribute](https://developer.mozilla.org/en/docs/Web/HTML/Element/meta#attr-http-equiv) to do URL redirection.

## Demo

[![asciicast](https://asciinema.org/a/132016.png)](https://asciinema.org/a/132016)

## Usage

You should export your personal GitHub access token as `GO_URL_SHORTENER_ACCESS_TOKEN`. Request one [here](https://github.com/settings/tokens) with the `repo` and `delete_repo` permissions.

Basic usage:

```sh
% git clone https://github.com/kashav/go-url-shortener && cd $_
% go build ./cmd/shortener/main.go
% ./main --help
usage: go-url-shortener [] [ ...]

Create and manage shortened URLs with GitHub pages.

Flags:
--[no-]help Show context-sensitive help (also try --help-long and --help-man).
--[no-]verbose Show detailed output.

Commands:
help [...]
Show help.

create []
Create a new entry.

list
Print a list of active entries.

remove ...
Remove one or more entries.

% ./main create --help
usage: go-url-shortener create []

Create a new entry.

Flags:
--[no-]help Show context-sensitive help (also try --help-long and --help-man).
--[no-]verbose Show detailed output.
-c, --cname=CNAME Optional CNAME record for this repository.
-n, --name=NAME Endpoint for the shortened URL, chosen randomly if empty.
-p, --[no-]private Make this repository private.
-s, --[no-]subdir Use a subdirectory in a pre-existing repository, instead of creating a new
repository.
-r, --repo=REPO A pre-existing repository to be used with the --subdir option (expects `foo/bar`
for `https://github.com/foo/bar`). Pushes to the default branch.

Args:
The URL to shorten.

% ./main list --help
usage: go-url-shortener list

Print a list of active entries.

Flags:
--[no-]help Show context-sensitive help (also try --help-long and --help-man).
--[no-]verbose Show detailed output.

% ./main remove --help
usage: go-url-shortener remove ...

Remove one or more entries.

Flags:
--[no-]help Show context-sensitive help (also try --help-long and --help-man).
--[no-]verbose Show detailed output.

Args:
List of entries to remove.
```