aboutsummaryrefslogtreecommitdiff
path: root/tools/govanity/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'tools/govanity/main.go')
-rw-r--r--tools/govanity/main.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/govanity/main.go b/tools/govanity/main.go
new file mode 100644
index 0000000..4afe8d1
--- /dev/null
+++ b/tools/govanity/main.go
@@ -0,0 +1,35 @@
+package repo
+
+import (
+ "html/template"
+ "net/http"
+)
+
+type repository struct {
+ Name string
+}
+
+var vanityTemplate = template.Must(template.New("code").Parse(`
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <meta name="go-import" content="src.fcuny.me{{.Name}} git https://github.com/fcuny/{{.Name}}">
+ <meta http-equiv="refresh" content="0; url=http://fcuny.me">
+ </head>
+ <body>
+ </body>
+</html>
+`))
+
+func init() {
+ http.HandleFunc("/", handleTransactions)
+}
+
+func handleTransactions(w http.ResponseWriter, r *http.Request) {
+ repoName := r.URL.Path
+ p := &repository{Name: repoName}
+ if err := vanityTemplate.Execute(w, p); err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
+}