Extract head to own template

This commit is contained in:
2016-12-07 16:42:56 +01:00
parent 1fa6c43df1
commit ed0b939a75
3 changed files with 24 additions and 25 deletions

29
main.go
View File

@@ -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")
}