updated validation for middleware options

This commit is contained in:
yusing
2024-11-30 04:00:55 +08:00
parent edc1ad952d
commit 6e9b5cc113
9 changed files with 97 additions and 94 deletions

View File

@@ -16,9 +16,9 @@ type realIP struct {
type realIPOpts struct {
// Header is the name of the header to use for the real client IP
Header string `json:"header"`
Header string `validate:"required"`
// From is a list of Address / CIDRs to trust
From []*types.CIDR `json:"from"`
From []*types.CIDR `validate:"min=1"`
/*
If recursive search is disabled,
the original client address that matches one of the trusted addresses is replaced by
@@ -27,7 +27,7 @@ type realIPOpts struct {
the original client address that matches one of the trusted addresses is replaced by
the last non-trusted address sent in the request header field.
*/
Recursive bool `json:"recursive"`
Recursive bool
}
var (