From 69973a0c0cea573d444d46b5ae69bebc1567a9b8 Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Sat, 28 May 2016 23:28:32 +0100 Subject: Define the token tmpl as a string --- cmd/cashierd/main.go | 8 ++++---- exampleconfig.json | 3 +-- templates/token.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ templates/token.html | 46 ---------------------------------------------- 4 files changed, 53 insertions(+), 52 deletions(-) create mode 100644 templates/token.go delete mode 100644 templates/token.html diff --git a/cmd/cashierd/main.go b/cmd/cashierd/main.go index 61461a7..2a8d2b8 100644 --- a/cmd/cashierd/main.go +++ b/cmd/cashierd/main.go @@ -13,7 +13,6 @@ import ( "log" "net/http" "os" - "path" "strings" "time" @@ -27,6 +26,7 @@ import ( "github.com/nsheridan/cashier/server/auth/google" "github.com/nsheridan/cashier/server/config" "github.com/nsheridan/cashier/server/signer" + "github.com/nsheridan/cashier/templates" ) var ( @@ -38,7 +38,6 @@ type appContext struct { cookiestore *sessions.CookieStore authprovider auth.Provider authsession *auth.Session - views *template.Template sshKeySigner *signer.KeySigner } @@ -154,7 +153,9 @@ func rootHandler(a *appContext, w http.ResponseWriter, r *http.Request) (int, er page := struct { Token string }{tok.AccessToken} - a.views.ExecuteTemplate(w, "token.html", page) + + tmpl := template.Must(template.New("token.html").Parse(templates.Token)) + tmpl.Execute(w, page) return http.StatusOK, nil } @@ -226,7 +227,6 @@ func main() { ctx := &appContext{ cookiestore: sessions.NewCookieStore([]byte(config.Server.CookieSecret)), authprovider: authprovider, - views: template.Must(template.ParseGlob(path.Join(config.Server.TemplateDir, "*"))), sshKeySigner: signer, } ctx.cookiestore.Options = &sessions.Options{ diff --git a/exampleconfig.json b/exampleconfig.json index cc4aca9..1ac84f2 100644 --- a/exampleconfig.json +++ b/exampleconfig.json @@ -4,8 +4,7 @@ "tls_key": "server.key", "tls_cert": "server.crt", "port": 443, - "cookie_secret": "supersecret", - "template_dir": "/go/src/github.com/nsheridan/cashier/templates" + "cookie_secret": "supersecret" }, "auth": { "provider": "google", diff --git a/templates/token.go b/templates/token.go new file mode 100644 index 0000000..dbad371 --- /dev/null +++ b/templates/token.go @@ -0,0 +1,48 @@ +package templates + +const Token = ` + + YOUR TOKEN! + + + +

+ This is your token. There are many like it but this one is yours. +

+ +

+ The token will expire in < 1 hour. +

+ +` diff --git a/templates/token.html b/templates/token.html deleted file mode 100644 index 4513176..0000000 --- a/templates/token.html +++ /dev/null @@ -1,46 +0,0 @@ - - - YOUR TOKEN! - - - -

- This is your token. There are many like it but this one is yours. -

- -

- The token will expire in < 1 hour. -

- - -- cgit v1.2.3