aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/cashierd/main.go8
-rw-r--r--exampleconfig.json3
-rw-r--r--templates/token.go (renamed from templates/token.html)6
3 files changed, 9 insertions, 8 deletions
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.html b/templates/token.go
index 4513176..dbad371 100644
--- a/templates/token.html
+++ b/templates/token.go
@@ -1,4 +1,6 @@
-<html>
+package templates
+
+const Token = `<html>
<head>
<title>YOUR TOKEN!</title>
<style>
@@ -43,4 +45,4 @@
The token will expire in &lt; 1 hour.
</h2>
</body>
-</html>
+</html>`