diff options
author | Franck Cuny <franck.cuny@gmail.com> | 2018-03-30 14:55:46 -0700 |
---|---|---|
committer | Franck Cuny <franck.cuny@gmail.com> | 2018-03-30 14:55:46 -0700 |
commit | b568e349e73ffcba7bf702dc25ab34d461b79ed1 (patch) | |
tree | d398b480a8b4faa8b6309cf422afbf62dd624221 /tools/govanity/main.go | |
parent | Initial commit (diff) | |
download | world-b568e349e73ffcba7bf702dc25ab34d461b79ed1.tar.gz |
Redirect go code to github.com
Diffstat (limited to '')
-rw-r--r-- | tools/govanity/main.go | 35 |
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) + } +} |