HTTP endpoints cleanup (#13251)

* remove validation package

* structs cleanup

* merge with apimiddleware removal

* more validation and Bls capitalization

* builder test fix

* use strconv for uint->str conversions

* use DecodeHexWithLength

* use exact param names

* rename http package to httputil

* change conversions to fmt.Sprintf

* handle query paramsd and route variables

* spans and receiver name

* split structs, move bytes helper

* missing ok check

* fix reference to indexed failure

* errors fixup

* add godoc to helper

* fix BLS casing and chainhead ref

* review

* fix import in tests

* gzl
This commit is contained in:
Radosław Kapka
2023-12-08 21:37:20 +01:00
committed by GitHub
parent 440841d565
commit 4c47756aed
121 changed files with 6048 additions and 6491 deletions

View File

@@ -1,6 +1,7 @@
package slice
import (
"fmt"
"strings"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
@@ -391,3 +392,12 @@ func Reverse[E any](s []E) []E {
}
return s
}
// VerifyMaxLength takes a slice and a maximum length and validates the length.
func VerifyMaxLength[T any](v []T, max int) error {
l := len(v)
if l > max {
return fmt.Errorf("length of %d exceeds max of %d", l, max)
}
return nil
}