Extract head to own template
This commit is contained in:
parent
1fa6c43df1
commit
ed0b939a75
21
main.go
21
main.go
@ -12,34 +12,31 @@ func main() {
|
|||||||
router.LoadHTMLGlob("./templates/*")
|
router.LoadHTMLGlob("./templates/*")
|
||||||
router.Static("/static", "./static")
|
router.Static("/static", "./static")
|
||||||
|
|
||||||
// Middleware
|
|
||||||
//e.Use(middleware.Logger())
|
|
||||||
//e.Use(middleware.Recover())
|
|
||||||
|
|
||||||
router.GET("/login.html", login)
|
router.GET("/login.html", login)
|
||||||
a := router.Group("/api/v1")
|
api := router.Group("/api/v1")
|
||||||
{
|
{
|
||||||
a.GET("/logout", logout)
|
api.GET("/logout", logout)
|
||||||
a.GET("/login", func(c *gin.Context) {
|
api.GET("/login", func(c *gin.Context) {
|
||||||
c.Redirect(http.StatusPermanentRedirect, "/login.html")
|
c.Redirect(http.StatusPermanentRedirect, "/login.html")
|
||||||
})
|
})
|
||||||
a.POST("/login", loginPost)
|
api.POST("/login", loginPost)
|
||||||
|
|
||||||
// Unauthenticated routes
|
// Unauthenticated routes
|
||||||
a.GET("/check", func(c *gin.Context) {
|
api.GET("/check", func(c *gin.Context) {
|
||||||
c.String(http.StatusOK, "Accessible")
|
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!")
|
c.String(http.StatusOK, "Hello, World!")
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
// Restricted group
|
// Restricted group
|
||||||
r := a.Group("/restricted")
|
r := api.Group("/restricted")
|
||||||
{
|
{
|
||||||
//r.Use(middleware.JWT([]byte(secret)))
|
//r.Use(middleware.JWT([]byte(secret)))
|
||||||
r.GET("", restricted)
|
r.GET("", restricted)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
router.Run(":1323")
|
router.Run(":1323")
|
||||||
}
|
}
|
||||||
|
10
templates/head.html
Normal file
10
templates/head.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{{define "head"}}
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||||
|
|
||||||
|
<link href="/static/css/bootstrap.min.css" rel="stylesheet" />
|
||||||
|
<link href="/static/css/bootstrap-theme.min.css" rel="stylesheet" />
|
||||||
|
<link href="/static/css/main.css" rel="stylesheet" />
|
||||||
|
|
||||||
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
|
||||||
|
<script src="http://malsup.github.com/jquery.form.js"></script>
|
||||||
|
{{end}}
|
@ -3,14 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>Login</title>
|
<title>Login</title>
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
{{template "head"}}
|
||||||
|
|
||||||
<link href="/static/css/bootstrap.min.css" rel="stylesheet" />
|
|
||||||
<link href="/static/css/bootstrap-theme.min.css" rel="stylesheet" />
|
|
||||||
<link href="/static/css/main.css" rel="stylesheet" />
|
|
||||||
|
|
||||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
|
|
||||||
<script src="http://malsup.github.com/jquery.form.js"></script>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -26,7 +19,6 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<head><title>Login</title>
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container" id="head">
|
<div class="container" id="head">
|
||||||
Budgeteer
|
Budgeteer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user