From b568e349e73ffcba7bf702dc25ab34d461b79ed1 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Fri, 30 Mar 2018 14:55:46 -0700 Subject: Redirect go code to github.com --- tools/govanity/Makefile | 6 ++++++ tools/govanity/README.md | 5 +++++ tools/govanity/app.yaml | 6 ++++++ tools/govanity/main.go | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 tools/govanity/Makefile create mode 100644 tools/govanity/README.md create mode 100644 tools/govanity/app.yaml create mode 100644 tools/govanity/main.go (limited to 'tools') 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(` + + + + + + + + + + +`)) + +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) + } +} -- cgit 1.4.1