Login form
This commit is contained in:
@ -1,11 +1,33 @@
|
||||
package views
|
||||
|
||||
import "github.com/kataras/iris/v12"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kataras/iris/v12"
|
||||
)
|
||||
|
||||
func GetIndexPage(ctx iris.Context) {
|
||||
params1 := []string{"param 1", "param 2", "param 3"}
|
||||
ctx.ViewData("params1", params1)
|
||||
ctx.ViewData("users", users)
|
||||
if err := ctx.View("pages/index.jet"); err != nil {
|
||||
showError(ctx, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
type loginForm struct {
|
||||
Email string `form:"email"`
|
||||
Password string `form:"password"`
|
||||
}
|
||||
|
||||
func PostIndexPage(ctx iris.Context) {
|
||||
var form loginForm
|
||||
err := ctx.ReadForm(&form)
|
||||
if err != nil {
|
||||
ctx.StopWithError(iris.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("email:", form.Email)
|
||||
fmt.Println("password:", form.Password)
|
||||
|
||||
if err := ctx.View("pages/index.jet"); err != nil {
|
||||
showError(ctx, err)
|
||||
|
||||
@ -4,6 +4,8 @@ import "github.com/kataras/iris/v12"
|
||||
|
||||
func CreateRouter(app *iris.Application) {
|
||||
app.Get("/", GetIndexPage)
|
||||
app.Post("/", PostIndexPage)
|
||||
|
||||
app.Get("/users", GetUsersPage)
|
||||
app.Get("/about", GetAboutPage)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user