diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-07 08:41:18 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-07 08:41:18 -0700 |
| commit | 79d1cff0755428edfc192448c04ed5a495264da5 (patch) | |
| tree | 76df56ba3906ae7fcf571c5fc2a35905dbdfc3ce /roseh.moe.go | |
| parent | bcc1c2d9dd7fefa538647c0d4e9e621511f1fde6 (diff) | |
| download | roseh.moe-79d1cff0755428edfc192448c04ed5a495264da5.tar.zst | |
Vanity url?
Diffstat (limited to 'roseh.moe.go')
| -rw-r--r-- | roseh.moe.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/roseh.moe.go b/roseh.moe.go index d3e96bf..3a2958c 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -440,6 +440,24 @@ func autosave(w http.ResponseWriter, r *http.Request) { } } +func cmd(w http.ResponseWriter, r *http.Request) { + var source string + switch r.PathValue("cmd") { + case "hole": + source = "git https://gitlab.com/rhogenson/roseh.moe.git tools/hole" + case "trash": + source = "git https://github.com/rhogenson/trash.git" + default: + notFound(w, r) + return + } + if r.FormValue("go-get") == "1" { + fmt.Fprintf(w, `<meta name="go-import" content="roseh.moe/cmd/%s %s">`, r.PathValue("cmd"), source) + } else { + http.Redirect(w, r, "https://pkg.go.dev/roseh.moe/cmd/"+r.PathValue("cmd"), http.StatusFound) + } +} + func main() { flag.Parse() @@ -455,6 +473,7 @@ func main() { http.HandleFunc("POST /login", login) http.HandleFunc("GET /notepad", notepad) http.HandleFunc("POST /notepad", autosave) + http.HandleFunc("GET /cmd/{cmd}", cmd) http.HandleFunc("GET /static/", static) http.HandleFunc("GET /favicon.ico", favicon) http.HandleFunc("GET /{$}", index) |
