diff --git a/main.go b/main.go index 9124d21..96b10d9 100644 --- a/main.go +++ b/main.go @@ -12,34 +12,31 @@ func main() { router.LoadHTMLGlob("./templates/*") router.Static("/static", "./static") - // Middleware - //e.Use(middleware.Logger()) - //e.Use(middleware.Recover()) - router.GET("/login.html", login) - a := router.Group("/api/v1") + api := router.Group("/api/v1") { - a.GET("/logout", logout) - a.GET("/login", func(c *gin.Context) { + api.GET("/logout", logout) + api.GET("/login", func(c *gin.Context) { c.Redirect(http.StatusPermanentRedirect, "/login.html") }) - a.POST("/login", loginPost) + api.POST("/login", loginPost) // Unauthenticated routes - a.GET("/check", func(c *gin.Context) { + api.GET("/check", func(c *gin.Context) { c.String(http.StatusOK, "Accessible") }) - a.GET("/hello", func(c *gin.Context) { + api.GET("/hello", func(c *gin.Context) { c.String(http.StatusOK, "Hello, World!") }) + + // Restricted group + r := api.Group("/restricted") + { + //r.Use(middleware.JWT([]byte(secret))) + r.GET("", restricted) + } } - // Restricted group - r := a.Group("/restricted") - { - //r.Use(middleware.JWT([]byte(secret))) - r.GET("", restricted) - } router.Run(":1323") } diff --git a/templates/head.html b/templates/head.html new file mode 100644 index 0000000..b2de638 --- /dev/null +++ b/templates/head.html @@ -0,0 +1,10 @@ +{{define "head"}} + + + + + + + + +{{end}} \ No newline at end of file diff --git a/templates/login.html b/templates/login.html index 78f2160..5d41fc1 100644 --- a/templates/login.html +++ b/templates/login.html @@ -3,14 +3,7 @@ Login - - - - - - - - + {{template "head"}} - Login