shortlinks
is a mutable shortlink server. The idea is that you can run it at
a very short domain and point shortlinks at documentation, dashboards, or whatever
for a given shortlink.
For example if I ran this (I currently do not) at s.frew.co
and pointed iam
at
https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html
,
s.frew.co/iam
would redirect to that big URL.
Instead of having a rigid permission model, shortlinks
is expected to run behind
a VPN. On top of that, shortlinks
stores historical versions of shortlinks so
if someone makes an undesired change, you can easily go back to a previous version
of that shortlink.
$ go install github.com/frioux/shortlinks@main
The default listen address is :8080 and the default database file is db.db
.
$ shortlinks --listen :8081 --db file:shortlinks.db
Then navigate to http://localhost:8081
and create your first shortlink!
In addition to simple links, a single %s
can be added to a link to be filled out based on what the input URL is.
Here's a table of some examples:
From | Query | To | Result |
---|---|---|---|
j | j | https://atlassian.net/browse/%s | https://atlassian.net/browse/ |
j | j/JIRA-000 | https://atlassian.net/browse/%s | https://atlassian.net/browse/JIRA-000 |
some | some/firstquery/secondquery | https://some.url/%s/else | https://some.url/firstquery/secondquery/else |
other | other/firstquery/secondquery | https://some.url/%s/else/%s | https://some.url/firstquery/secondquery/else/%s |
Note that only 1 substution is performed. If more than one %s
is in the To value, the rest will be ignored.
If no argument is given then empty string, "" is used.
This tool is built to be easy to run using SQLite. If you want to use some
other relational database or key value store more appropriate for your
infrastructure, all you need to do is create your own implementation of
shortlinks.DB.
The only methods that need to actually work are Shortlink
and
CreateShortlink
, the rest can be left as stubs.
Similarly, there is a shortlinks.Auth interface that you can use to only allow logged in users to make changes. I have an example driver using tailscale and am eager to hear if the interface is sufficient for other auth methods.
The DynamoDB Storage driver (enabled by the --dynamodb
flag) works, but is
currently unconfigurable. Patches welcome to configure region, table name,
endpoint, etc.