Add login Website
This commit is contained in:
parent
c5d8e858a4
commit
d8860aabc8
13
main.go
13
main.go
@ -23,6 +23,7 @@ func main() {
|
||||
|
||||
a := router.Group("/api/v1")
|
||||
{
|
||||
a.GET("/login", login)
|
||||
a.POST("/login", loginPost)
|
||||
|
||||
// Unauthenticated routes
|
||||
@ -51,6 +52,18 @@ func restricted(c *gin.Context) {
|
||||
c.String(http.StatusOK, "Welcome "+name+"!")
|
||||
}
|
||||
|
||||
func login(c *gin.Context) {
|
||||
c.String(http.StatusOK, `<html>
|
||||
<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) {
|
||||
username, _ := c.GetPostForm("username")
|
||||
password, _ := c.GetPostForm("password")
|
||||
|
Loading…
x
Reference in New Issue
Block a user