Aded test coverage for form submissions. Added validator as a service.
This commit is contained in:
parent
cc2f25431b
commit
6501621136
8 changed files with 111 additions and 30 deletions
|
|
@ -8,8 +8,6 @@ import (
|
|||
"goweb/middleware"
|
||||
"goweb/services"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/labstack/echo-contrib/session"
|
||||
|
||||
|
|
@ -17,19 +15,6 @@ import (
|
|||
echomw "github.com/labstack/echo/v4/middleware"
|
||||
)
|
||||
|
||||
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 *services.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
|
||||
|
|
@ -73,9 +58,6 @@ func BuildRouter(c *services.Container) {
|
|||
err := Error{Controller: ctr}
|
||||
c.Web.HTTPErrorHandler = err.Get
|
||||
|
||||
// Validator
|
||||
c.Web.Validator = &Validator{validator: validator.New()}
|
||||
|
||||
// Routes
|
||||
navRoutes(c, g, ctr)
|
||||
userRoutes(c, g, ctr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue