diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2026-07-09 20:08:37 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2026-07-09 20:08:37 -0700 |
| commit | 454214e78be73afa8784d283ac0aa01baeacc996 (patch) | |
| tree | 099be3b7c9509c753a1147e583310cca375a9598 | |
| parent | de52ffdd1412590ea733942500534f62cfa1b84c (diff) | |
| download | roseh.moe-454214e78be73afa8784d283ac0aa01baeacc996.tar.zst | |
Use PUT for the API
| -rw-r--r-- | roseh.moe.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/roseh.moe.go b/roseh.moe.go index 6ac91e9..f71761c 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -499,8 +499,11 @@ func wormholeAPIUpload(w http.ResponseWriter, r *http.Request) { http.Error(w, "Failed to write hole file", http.StatusInternalServerError) return } + resultURL := fmt.Sprintf("%s/wormhole/%s", *selfURL, hole) w.Header().Set("Content-Type", "text/plain") - fmt.Fprintf(w, "%s/wormhole/%s\n", *selfURL, hole) + w.Header().Set("Location", resultURL) + w.WriteHeader(http.StatusCreated) + fmt.Fprintln(w, resultURL) } func wormholeDownload(w http.ResponseWriter, r *http.Request) { @@ -852,7 +855,7 @@ func main() { mux.Handle("GET /code/", http.StripPrefix("/code/", http.FileServer(http.Dir(*codeDir)))) mux.HandleFunc("GET /static/", static) mux.HandleFunc("GET /favicon.ico", favicon) - mux.HandleFunc("POST /api/wormhole/{name}", wormholeAPIUpload) + mux.HandleFunc("PUT /api/wormhole/{name}", wormholeAPIUpload) mux.HandleFunc("GET /", notFound) http.Handle("/", http.NewCrossOriginProtection().Handler(mux)) jellyfinURL, err := url.Parse("http://127.0.0.1:8096") |
