From 1350761ee9e2d4522f50ebf02f8f24197690e33f Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sat, 15 Nov 2025 13:38:15 -0800 Subject: rewrite the go import HTML --- app/fcuny-net/main.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'app/fcuny-net/main.go') diff --git a/app/fcuny-net/main.go b/app/fcuny-net/main.go index 9a8a4f2..672e4ef 100644 --- a/app/fcuny-net/main.go +++ b/app/fcuny-net/main.go @@ -31,9 +31,8 @@ var staticFiles embed.FS var templateFiles embed.FS const ( - domain = "fcuny.net" - forgeDomain = "code.fcuny.net" - forgeUser = "fcuny" + domain = "fcuny.net" + packageDomain = "code.fcuny.net" ) type PageData struct { @@ -135,7 +134,7 @@ func handler() http.Handler { module := "/" + name mux.Handle( module+"/", - goImportHandler(module, "https://"+forgeDomain+"/"+forgeUser+"/"+name), + goImportHandler(module, "https://"+packageDomain+"/"+name), ) } @@ -234,8 +233,18 @@ func goImportHandler(module, repo string) http.Handler { if r.URL.Query().Get("go-get") == "1" { w.Header().Set("Content-Type", "text/html; charset=UTF-8") importPath := domain + module - if _, err := fmt.Fprintf(w, ``, importPath, repo); err != nil { + + const goImportHTML = ` + + + + +go get %[1]s +` + + if _, err := fmt.Fprintf(w, goImportHTML, importPath, repo); err != nil { log.Printf("Error writing response: %v", err) + http.Error(w, "Internal Server Error", http.StatusInternalServerError) } return } -- cgit v1.2.3