about summary refs log tree commit diff
path: root/tools/govanity/main.go
blob: 4afe8d1c98adce1580c5e411cbb6d95607d501a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)
	}
}