aboutsummaryrefslogtreecommitdiff
path: root/tools/govanity
diff options
context:
space:
mode:
Diffstat (limited to 'tools/govanity')
-rw-r--r--tools/govanity/Makefile6
-rw-r--r--tools/govanity/README.md5
-rw-r--r--tools/govanity/app.yaml6
-rw-r--r--tools/govanity/main.go35
4 files changed, 52 insertions, 0 deletions
diff --git a/tools/govanity/Makefile b/tools/govanity/Makefile
new file mode 100644
index 0000000..939497d
--- /dev/null
+++ b/tools/govanity/Makefile
@@ -0,0 +1,6 @@
+.PHONY: deploy
+deploy:
+ gcloud -q app deploy --project=fcuny-govanity
+
+.PHONY: all
+all: deploy
diff --git a/tools/govanity/README.md b/tools/govanity/README.md
new file mode 100644
index 0000000..0c1f061
--- /dev/null
+++ b/tools/govanity/README.md
@@ -0,0 +1,5 @@
+A service to manage vanity URLs for go packages.
+
+## Deployment
+
+To update the application with the most recent code, run `make all`.
diff --git a/tools/govanity/app.yaml b/tools/govanity/app.yaml
new file mode 100644
index 0000000..40f1c9f
--- /dev/null
+++ b/tools/govanity/app.yaml
@@ -0,0 +1,6 @@
+runtime: go
+api_version: go1
+
+handlers:
+ - url: /.*
+ script: _go_app
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)
+ }
+}