Remove ill-advised code

This commit is contained in:
jdl 2025-03-30 11:16:27 +02:00
parent 060426fd64
commit e20a966475

View File

@ -8,17 +8,9 @@ import (
var ErrUnsupportedType = errors.New("unsupported type")
// FormScanFunc is a custom form scanner that can be used to scan custom
// types using the form scanner.
//
// It returns true if it recognizes the type of val, and an error if scanning
// fails.
type FormScanFunc func(name, formVal string, val any) (bool, error)
type FormScanner struct {
form url.Values
err error
ScanFunc FormScanFunc // TODO: Remove?
form url.Values
err error
}
func NewFormScanner(form url.Values) *FormScanner {
@ -30,13 +22,6 @@ func (s *FormScanner) Scan(name string, val any) *FormScanner {
return s
}
if s.ScanFunc != nil {
if ok, err := s.ScanFunc(name, s.form.Get(name), val); ok {
s.err = err
return s
}
}
switch v := val.(type) {
case *bool:
*v = s.form.Has(name)
@ -52,3 +37,7 @@ func (s *FormScanner) Scan(name string, val any) *FormScanner {
func (s *FormScanner) Error() error {
return s.err
}
func (s *FormScanner) SetError(err error) {
s.err = err
}