Handle user creation upon registration.

This commit is contained in:
mikestefanello 2021-12-11 13:03:10 -05:00
parent 79d2db3c1f
commit 8657380530
13 changed files with 201 additions and 46 deletions

View file

@ -6,6 +6,8 @@ import (
"goweb/config"
"goweb/middleware"
"github.com/go-playground/validator/v10"
"github.com/gorilla/sessions"
"github.com/labstack/echo-contrib/session"
@ -15,6 +17,19 @@ import (
"goweb/container"
)
type Validator struct {
validator *validator.Validate
}
func (v *Validator) Validate(i interface{}) error {
if err := v.validator.Struct(i); err != nil {
return err
}
return nil
}
// TODO: This is doing more than building the router
func BuildRouter(c *container.Container) {
// Static files with proper cache control
// funcmap.File() should be used in templates to append a cache key to the URL in order to break cache
@ -50,6 +65,9 @@ func BuildRouter(c *container.Container) {
err := Error{Controller: ctr}
c.Web.HTTPErrorHandler = err.Get
// Validator
c.Web.Validator = &Validator{validator: validator.New()}
// Routes
navRoutes(g, ctr)
userRoutes(g, ctr)