Documentation
¶
Overview ¶
Package simplevalidate contains a Validator for secrets that can be validated with simple HTTP queries and result code comparison.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Validator ¶
type Validator[S veles.Secret] struct { // The API endpoint to query. Endpoint string // Function that constructs the endpoint for a given secret. // Exactly one of Endpoint or EndpointFunc must be provided. // The specificed endpoints get queried in order and the validation is considered valid // if either of them return a valid status. // If EndpointFunc returns an error, Validate returns ValidationFailed and the error. EndpointFunc func(S) (string, error) // The API endpoints to query. // The specificed endpoints get queried in order and the validation is considered valid // if either of them return a valid status. Endpoints []string // Function that constructs the endpoints for a given secret. // Exactly one of Endpoints or EndpointFuncs must be provided. // If EndpointsFunc returns an error, Validate returns ValidationFailed and the error. EndpointsFunc func(S) ([]string, error) // The HTTP request method to send (e.g. http.MethodGet, http.MethodPost) HTTPMethod string // HTTP headers to set in the query based on the secret. HTTPHeaders func(S) map[string]string // The body to set in the query based on the secret. // If Body returns an error, Validate returns ValidationFailed and the error. Body func(S) (string, error) // Status codes that should result in a "ValidationValid" validation result. ValidResponseCodes []int // Status codes that should result in a "ValidationInvalid" validation result. InvalidResponseCodes []int // Additional custom validation logic to perform on the response body. Will run if none of the // status codes from ValidResponseCodes and InvalidResponseCodes have been found. StatusFromResponseBody func(body io.Reader) (veles.ValidationStatus, error) // The HTTP client to use for the network queries. Uses http.DefaultClient if nil. HTTPC *http.Client }
Validator validates a secret of a given type by sending HTTP requests and checking the response status code. It implements veles.Validator.
Click to show internal directories.
Click to hide internal directories.