go-shrt

Shortlinks and go-get redirects
git clone git://git.danielmoch.com/go-shrt.git
Log | Files | Refs | README | LICENSE

commit d87aa25655dce02992e414a978024eccf1c0b2e5
parent 34109df6b2a9441c5bd9f8f1021df0237fd79101
Author: glenda <glenda@9front.local>
Date:   Sun, 15 Nov 2020 01:23:43 +0000

Add bare redirect

Diffstat:
Mmain.go | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/main.go b/main.go @@ -40,6 +40,14 @@ func handl(w http.ResponseWriter, req *http.Request) { key = key[1:] } + if key == "" && (*cfg)["barerdr"] != "" { + log.Println("shortlink request for /") + w.Header().Add("Location", (*cfg)["barerdr"]) + w.WriteHeader(http.StatusFound) + w.Write([]byte("Redirecting\n")) + return + } + if req.URL.Query().Get("go-get") == "1" { repo := key log.Println("go-get request for", repo)