Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶
func NewDispatcher(stubReg StubRegistry, router *openapi.Router, maxDepth int, staticSeed, onlyStubs bool, logger *fauxlog.Logger) *Dispatcher
func (*Dispatcher) ServeHTTP ¶
func (d *Dispatcher) ServeHTTP(w http.ResponseWriter, req *http.Request) bool
type NormalizedRequest ¶
type NormalizedRequest struct {
Service string `json:"service,omitempty"`
Method string `json:"method,omitempty"`
OperationID string `json:"operationId,omitempty"`
Path string `json:"path,omitempty"`
HTTPMethod string `json:"httpMethod,omitempty"`
PathParams map[string]string `json:"pathParams,omitempty"`
QueryParams map[string]string `json:"queryParams,omitempty"`
Headers http.Header `json:"headers,omitempty"`
Body []byte `json:"body,omitempty"`
}
NormalizedRequest standardizes requests across gRPC/Connect and HTTP/REST.
type NormalizedResponse ¶
type NormalizedResponse struct {
Status int `json:"status"`
Headers http.Header `json:"headers,omitempty"`
Body any `json:"body,omitempty"`
RawBody []byte `json:"rawBody,omitempty"`
}
NormalizedResponse represents a response returned by stubs or generator.
type StubMatch ¶
type StubMatch struct {
PathParams map[string]string `json:"pathParams,omitempty" yaml:"pathParams,omitempty"`
QueryParams map[string]string `json:"queryParams,omitempty" yaml:"queryParams,omitempty"`
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
BodyExpression string `json:"bodyExpression,omitempty" yaml:"bodyExpression,omitempty"`
}
StubMatch holds predicates to evaluate against NormalizedRequest.
type StubRegistry ¶
type StubRegistry interface {
AddStub(rule StubRule)
FindMatch(req *NormalizedRequest) (*StubRule, bool)
Clear()
NumStubs() int
}
type StubResponse ¶
type StubResponse struct {
Status int `json:"status" yaml:"status"`
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
Body any `json:"body,omitempty" yaml:"body,omitempty"`
}
StubResponse holds response details.
type StubRule ¶
type StubRule struct {
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Target TargetRef `json:"target" yaml:"target"`
Match StubMatch `json:"match,omitempty" yaml:"match,omitempty"`
Response StubResponse `json:"response" yaml:"response"`
Priority int `json:"priority,omitempty" yaml:"priority,omitempty"`
Specificity int `json:"-" yaml:"-"`
}
StubRule represents a unified stub rule for gRPC or REST.
type TargetRef ¶
type TargetRef struct {
Service string `json:"service,omitempty" yaml:"service,omitempty"`
Method string `json:"method,omitempty" yaml:"method,omitempty"`
OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"`
Path string `json:"path,omitempty" yaml:"path,omitempty"`
HTTPMethod string `json:"httpMethod,omitempty" yaml:"httpMethod,omitempty"`
}
TargetRef identifies the target endpoint for stub matching.
Click to show internal directories.
Click to hide internal directories.