Move HTML to template
This commit is contained in:
parent
d8860aabc8
commit
73950eb6da
11
main.go
11
main.go
@ -16,6 +16,7 @@ const (
|
|||||||
func main() {
|
func main() {
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
|
|
||||||
|
router.LoadHTMLGlob("./templates/*")
|
||||||
// Middleware
|
// Middleware
|
||||||
//e.Use(middleware.Logger())
|
//e.Use(middleware.Logger())
|
||||||
//e.Use(middleware.Recover())
|
//e.Use(middleware.Recover())
|
||||||
@ -53,15 +54,7 @@ func restricted(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func login(c *gin.Context) {
|
func login(c *gin.Context) {
|
||||||
c.String(http.StatusOK, `<html>
|
c.HTML(http.StatusOK, "login.html", nil)
|
||||||
<head><title>Login</title>
|
|
||||||
<body>
|
|
||||||
<form action=\"login\">
|
|
||||||
<input type=\"text\" name=\"username\" />
|
|
||||||
<input type=\"password\" name=\"password\" />
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loginPost(c *gin.Context) {
|
func loginPost(c *gin.Context) {
|
||||||
|
14
templates/login.html
Normal file
14
templates/login.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<html>
|
||||||
|
<head><title>Login</title>
|
||||||
|
<body>
|
||||||
|
<form action="/api/v1/login?target=/" method="POST">
|
||||||
|
<label for="username">User</label>
|
||||||
|
<input type="text" name="username" /><br />
|
||||||
|
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<input type="password" name="password" /><br />
|
||||||
|
|
||||||
|
<input type="submit">Login</form>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user