From a970da095c26ec0d1c10f93f09bae2502e3ad77e Mon Sep 17 00:00:00 2001 From: swirl Date: Sun, 8 Aug 2021 19:52:45 -0400 Subject: [PATCH] update --- index.html | 209 +++++++++++++++++++++++++++++++++++++---------------- main.go | 85 +++++++++++++++------- 2 files changed, 204 insertions(+), 90 deletions(-) diff --git a/index.html b/index.html index f0b245c..7c27197 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,14 @@ - - A Minimal, SQLite-Backed URL Shortener - - - - - - - + + A Minimal, SQLite-Backed URL Shortener + + + + + + +
A Minimal, SQLite-Backed URL Shortener @@ -16,72 +16,153 @@ A Minimal, SQLite-Backed URL Shortener
| Examples:
-| 
+|
 | 1. Create a short link to https://duckduckgo.com
-| 	$ curl -d https://duckduckgo.com {{.URL}}
-| 	{{.URL}}/502fb5543c36014f
-| 
+|   $ 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. Deleting a short link
-| 	$ TMP=$(mktemp)
-| 	$ # temp file will store 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')
-| 	$ # deletion key is stored in '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.
- +| $ curl -d https://duckduckgo.com {{.URL}}/ddg +| {{.URL}}/ddg +| +| 3. Create a short link to https://duckduckgo.com uaing 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. Deleting a short link +| $ TMP=$(mktemp) +| $ # temp file will store 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') +| $ # deletion key is stored in '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. + {{if .Demo}}

-Please note: this is an example deployment. If you attempt to create a short +Please note: this is an example deployment. If you attempt to create a short link here you will receive a 401 Unauthorized. If you like the examples above and want to use this URL shortener you should self-host an instance. It's easy to do (one of the design goals). Below are instructions detailing how.

- -

| How to self-host:
-| 
-| 1. Install dependencies
-| 	a. The Go programming language
-| 		https://golang.org/doc/install
-| 	b. Git version control
-| 		https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
-| 
-| 	* On FreeBSD this would be: 
-| 		$ pkg install -y go git 
-| 
-| 2. Fetch, complile, and execute the source code
-| 	$ env GO111MODULE=off go get git.fsh.ee/i/link
-| 	$ env GO111MODULE=off go run git.fsh.ee/i/link -url https://your.domain.com -port 8080 -db /path/to/sqlite/file -seed secret
-| 
-| * The server is now running on localhost at port 8080.
-| * If the SQLite database at this filepath does not exist it will be created.
-| * All logging will be printed to standard error and standard output.
{{end}} - -