summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roseh.moe.go19
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)