diff options
Diffstat (limited to '')
| -rw-r--r-- | app/fcuny-net/main.go | 19 |
1 files changed, 14 insertions, 5 deletions
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, `<html><head><meta name="go-import" content="%s git %s"></head></html>`, importPath, repo); err != nil { + + const goImportHTML = `<html> +<head> + <meta name="go-import" content="%[1]s git %[2]s"> + <meta name="go-source" content="%[1]s _ %[2]s/tree{/dir} %[2]s/tree{/dir}/{file}#n{line}"> +</head> +<body>go get %[1]s</body> +</html>` + + 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 } |
