aboutsummaryrefslogtreecommitdiff
path: root/tools/govanity/main.go
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2018-03-30 14:55:46 -0700
committerFranck Cuny <franck.cuny@gmail.com>2018-03-30 14:55:46 -0700
commitb568e349e73ffcba7bf702dc25ab34d461b79ed1 (patch)
treed398b480a8b4faa8b6309cf422afbf62dd624221 /tools/govanity/main.go
parentInitial commit (diff)
downloadinfra-b568e349e73ffcba7bf702dc25ab34d461b79ed1.tar.gz
Redirect go code to github.com
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)
+ }
+}