mirror of
https://git.swurl.xyz/swirl/link.git
synced 2023-11-08 10:44:52 +02:00
6abaf1abbb
removed all SQLite stuff, and switched to a fully filesystem-based storage system, which just uses plain files. also moved self-host instructions to README
72 lines
2.2 KiB
HTML
72 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang=en>
|
|
<head>
|
|
<title>A Minimal, Filesystem-Backed URL Shortener</title>
|
|
<meta charset='utf-8'>
|
|
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
|
|
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
|
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
<meta content='A super simple, minimal, and filesystem-backed URL Shortener.' name='description'>
|
|
</head>
|
|
<body style='font-family: monospace; max-width: 80ch;'>
|
|
|
|
<header>
|
|
A Minimal, Filesystem-Backed URL Shortener
|
|
</header>
|
|
|
|
<style>
|
|
@media (max-width: 1000px) {
|
|
pre code {
|
|
display: block;
|
|
max-width: 100%%;
|
|
overflow-x: auto;
|
|
-webkit-overflow-scrolling: touch;
|
|
padding: 0 5px 5px 0;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<pre><code>| Examples:
|
|
|
|
|
| 1. Create a short link to https://duckduckgo.com
|
|
| $ curl -d https://duckduckgo.com {{.URL}}
|
|
| {{.URL}}/502fb5543c36014f
|
|
|
|
|
| 2. Create a short link with a custom path
|
|
| $ curl -d https://duckduckgo.com {{.URL}}/ddg
|
|
| {{.URL}}/ddg
|
|
|
|
|
| 3. Create a short link to https://duckduckgo.com using a query string
|
|
| $ curl {{.URL}}?https://duckduckgo.com
|
|
| {{.URL}}/1acd382417199d7e
|
|
|
|
|
| 4. Create a short link with a custom path using a query string
|
|
| $ curl {{.URL}}/ddg?https://duckduckgo.com
|
|
| {{.URL}}/ddg
|
|
|
|
|
| 5. You can also pass an encoded URL:
|
|
| $ curl {{.URL}}?https%3A%2F%2Fduckduckgo.com
|
|
| {{.URL}}/1dc4cb37e81de396
|
|
|
|
|
| 6. Deleting a short link
|
|
| $ TMP=$(mktemp)
|
|
| $ # the temp file will store the header
|
|
| $ LINK=$(curl -sS {{.URL}} -d https://duckduckgo.com -D $TMP)
|
|
| $ # the link has been successfully created
|
|
| $ DEL=$(cat $TMP | grep -i delete-with | awk '{print$2}'| tr -d '\r')
|
|
| $ # the deletion key is stored in the 'X-Delete-With' header
|
|
| $ curl $LINK
|
|
| <a href="https://duckduckgo.com">Permanent Redirect</a>.
|
|
| $ # the link is working as expected
|
|
| $ curl $LINK -X DELETE -d $DEL
|
|
| $ curl $LINK
|
|
| record not found
|
|
| $ # the link has been successfully deleted</code></pre>
|
|
|
|
<footer style='white-space: pre;'>Source code: <a href='https://short.swurl.xyz/src'>short.swurl.xyz/src</a></a>
|
|
License: AGPL v3{{if .Copy}}
|
|
Copy: {{.Copy}}{{end}}
|
|
Made with: Go, Neovim, and Gentoo/Arch Linux
|
|
</footer>
|
|
</html>
|