Extract head to own template
This commit is contained in:
29
main.go
29
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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user