Created
June 2, 2018 15:41
-
-
Save Cibernomadas/89e8d64c24a13c8bf147321905da4c8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loginFn(c *gin.Context) { | |
if c.Request.Method == http.MethodGet { // Serve login page | |
c.HTML(http.StatusOK, "index", gin.H{ | |
"title": "Hi! GoBlog.", | |
}) | |
} else if c.Request.Method == http.MethodPost { // Process login | |
var login loginForm | |
if err := c.ShouldBind(&login); err == nil { | |
// TODO: | |
} else { | |
c.HTML(http.StatusOK, "index", gin.H{ | |
"title": "Hi! GoBlog.", | |
"error": "Required fields not provided.", | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment