Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.