From 73950eb6da1f848f077baa5da61b9451956c1342 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Wed, 23 Nov 2016 22:07:53 +0100 Subject: [PATCH] Move HTML to template --- main.go | 11 ++--------- templates/login.html | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 templates/login.html diff --git a/main.go b/main.go index 5b72ed6..96cc713 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ const ( func main() { router := gin.Default() + router.LoadHTMLGlob("./templates/*") // Middleware //e.Use(middleware.Logger()) //e.Use(middleware.Recover()) @@ -53,15 +54,7 @@ func restricted(c *gin.Context) { } func login(c *gin.Context) { - c.String(http.StatusOK, ` - Login - -
- - -
- - `) + c.HTML(http.StatusOK, "login.html", nil) } func loginPost(c *gin.Context) { diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..a04ff6b --- /dev/null +++ b/templates/login.html @@ -0,0 +1,14 @@ + + Login + +
+ +
+ + +
+ + Login
+ + + \ No newline at end of file