Skip to content

Instantly share code, notes, and snippets.

@Cibernomadas
Created June 2, 2018 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cibernomadas/89e8d64c24a13c8bf147321905da4c8b to your computer and use it in GitHub Desktop.
Save Cibernomadas/89e8d64c24a13c8bf147321905da4c8b to your computer and use it in GitHub Desktop.
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