Add login Website

This commit is contained in:
Jan Bader 2016-11-23 21:51:55 +01:00
parent c5d8e858a4
commit d8860aabc8

13
main.go
View File

@ -23,6 +23,7 @@ func main() {
a := router.Group("/api/v1") a := router.Group("/api/v1")
{ {
a.GET("/login", login)
a.POST("/login", loginPost) a.POST("/login", loginPost)
// Unauthenticated routes // Unauthenticated routes
@ -51,6 +52,18 @@ func restricted(c *gin.Context) {
c.String(http.StatusOK, "Welcome "+name+"!") 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) { func loginPost(c *gin.Context) {
username, _ := c.GetPostForm("username") username, _ := c.GetPostForm("username")
password, _ := c.GetPostForm("password") password, _ := c.GetPostForm("password")