Documentation
¶
Index ¶
- func ValidateResponse(actual, expected interface{}) error
- func ValidateResponseEnhanced(actual, expected interface{}) error
- type Client
- func (c *Client) Call(ctx context.Context, method string, params interface{}) (*Response, error)
- func (c *Client) CallHTTP(ctx context.Context, method, path string, body interface{}, ...) (*HTTPResponse, error)
- func (c *Client) CallHTTPDelete(ctx context.Context, path string, headers map[string]string) (*HTTPResponse, error)
- func (c *Client) CallHTTPGet(ctx context.Context, path string, headers map[string]string) (*HTTPResponse, error)
- func (c *Client) CallHTTPPost(ctx context.Context, path string, body interface{}, headers map[string]string) (*HTTPResponse, error)
- func (c *Client) CallHTTPPut(ctx context.Context, path string, body interface{}, headers map[string]string) (*HTTPResponse, error)
- type Error
- type HTTPResponse
- type Request
- type Response
- type ValidatorConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateResponse ¶
func ValidateResponse(actual, expected interface{}) error
ValidateResponse validates the response against expected values Returns nil if validation passes, error otherwise
func ValidateResponseEnhanced ¶ added in v0.7.0
func ValidateResponseEnhanced(actual, expected interface{}) error
ValidateResponseEnhanced provides enhanced validation with support for: - Range validation (min/max) - Pattern matching (regex) - Type checking - Approximate float comparison - Array validation - Object validation
Example YAML usage:
expected:
# Simple value (backward compatible)
status: "ok"
# Range validation
count:
min: 1
max: 10
# Pattern validation
user_id:
pattern: "^user_\\d+$"
# Type validation
timestamp:
type: "number"
# Approximate float
rate:
approx: 0.75
tolerance: 0.01
Types ¶
type Client ¶
Client is an HTTP client that supports both JSON-RPC 2.0 and REST API
func (*Client) CallHTTP ¶ added in v0.7.1
func (c *Client) CallHTTP(ctx context.Context, method, path string, body interface{}, headers map[string]string) (*HTTPResponse, error)
CallHTTP makes a simple HTTP request (non-JSON-RPC) Supports GET, POST, PUT, DELETE methods
func (*Client) CallHTTPDelete ¶ added in v0.7.1
func (c *Client) CallHTTPDelete(ctx context.Context, path string, headers map[string]string) (*HTTPResponse, error)
CallHTTPDelete makes a simple HTTP DELETE request
func (*Client) CallHTTPGet ¶ added in v0.7.1
func (c *Client) CallHTTPGet(ctx context.Context, path string, headers map[string]string) (*HTTPResponse, error)
CallHTTPGet makes a simple HTTP GET request
func (*Client) CallHTTPPost ¶ added in v0.7.1
func (c *Client) CallHTTPPost(ctx context.Context, path string, body interface{}, headers map[string]string) (*HTTPResponse, error)
CallHTTPPost makes a simple HTTP POST request
func (*Client) CallHTTPPut ¶ added in v0.7.1
func (c *Client) CallHTTPPut(ctx context.Context, path string, body interface{}, headers map[string]string) (*HTTPResponse, error)
CallHTTPPut makes a simple HTTP PUT request
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
Error represents a JSON-RPC 2.0 error
type HTTPResponse ¶ added in v0.7.1
HTTPResponse represents a simple HTTP response (non-JSON-RPC)
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params interface{} `json:"params,omitempty"`
ID interface{} `json:"id"`
}
Request represents a JSON-RPC 2.0 request
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
Result interface{} `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
ID interface{} `json:"id"`
}
Response represents a JSON-RPC 2.0 response
type ValidatorConfig ¶ added in v0.7.0
type ValidatorConfig struct {
// Range validation
Min *float64 `json:"min,omitempty"`
Max *float64 `json:"max,omitempty"`
// Pattern validation (regex)
Pattern *string `json:"pattern,omitempty"`
// Type validation
Type *string `json:"type,omitempty"`
// Approximate float comparison
Approx *float64 `json:"approx,omitempty"`
Tolerance *float64 `json:"tolerance,omitempty"`
// Array validation
Length *int `json:"length,omitempty"`
MinLength *int `json:"minLength,omitempty"`
MaxLength *int `json:"maxLength,omitempty"`
Contains []interface{} `json:"contains,omitempty"`
// Object validation
HasFields []string `json:"hasFields,omitempty"`
MissingFields []string `json:"missingFields,omitempty"`
}
ValidatorConfig represents extended validation configuration