hlfw.ca

webbing

ref: cc4256ab632d02991ff81c246ed8e4940f717c4a
dir: /errors.go/

View raw version
package plugins

import (
	"github.com/olmaxmedical/router"
)

// FormErrors - A list of errors present on a POST request
const FormErrors router.PluginMask = 1 << 8

func init() {
	b := &router.Plugin{
		Name:     "errors",
		Run:      GetFormErrors,
		Validate: nil,
	}
	router.AddPlugin(b, FormErrors)
}

// GetFormErrors - return the client a list of any errors in the form
func GetFormErrors(r *router.Request) map[string]interface{} {
	s := r.Session()
	if s == nil {
		return nil
	}
	return map[string]interface{}{
		"errors": s.Get("errors"),
	}
}