Versions in this module Expand all Collapse all v0 v0.0.7 Oct 12, 2023 Changes in this version type Operator + func OpUrlEqualTo(actualURL string) Operator v0.0.6 Oct 11, 2023 v0.0.6-beta4 Oct 11, 2023 v0.0.6-beta3 Oct 11, 2023 v0.0.6-beta2 Oct 10, 2023 v0.0.6-beta Oct 10, 2023 v0.0.5 Oct 10, 2023 v0.0.4 Oct 10, 2023 v0.0.3 Oct 10, 2023 Changes in this version type IncomingRequest + func (IncomingRequest) TableName() string type Stub + func (Stub) TableName() string v0.0.2 Oct 5, 2023 v0.0.1 Oct 5, 2023 Changes in this version + const ContentTypeForm + const ContentTypeHTML + const ContentTypeJSON + const ContentTypeMultipart + const ContentTypeText + const ContentTypeXML + const Debug + const HeaderContentLength + const HeaderContentType + const HeaderLocation + const HeaderXRequestID + const MethodGrpc + const ProtocolGrpc + const ProtocolHTTP + const Release + const ResetAll + const TagRecordedStub + var AllSupportedOperators = []OperatorName + var ReleaseMode = Release + func HTMLContent(html string) (string, []byte) + func Match(ctx context.Context, op Operator, value interface{}) (bool, error) + func MustToJSON(v interface{}) (string, []byte) + func MustToXML(v interface{}) (string, []byte) + type ArrayStubs struct + Stubs []*Stub + type Body []byte + func (m *Body) UnmarshalJSON(data []byte) error + func (m *Body) UnmarshalYAML(unmarshal func(interface{}) error) error + type BodyOperator struct + ContentType string + KeyPath string + Operator Operator + type Cookie struct + ExpiredAt time.Time + Name string + Value string + type CreateBodyOperator func() BodyOperator + func BodyJSONPath(jsonPath string, createOperator CreateOperator) CreateBodyOperator + func MultiPartForm(key string, createOperator CreateOperator) CreateBodyOperator + func URLEncodedBody(key string, createOperator CreateOperator) CreateBodyOperator + type CreateOperator func() Operator + func Contains(v interface{}) CreateOperator + func Empty() CreateOperator + func EndWith(v string) CreateOperator + func EqualTo(v interface{}) CreateOperator + func Length(v int) CreateOperator + func NotContains(v interface{}) CreateOperator + func NotEmpty() CreateOperator + func Regex(v string) CreateOperator + func StartWith(v string) CreateOperator + type ErrorDetail struct + Type string + Value types.Map + type FieldOperator struct + FieldName string + Operator Operator + func (o FieldOperator) String() string + type GrpcRequest struct + FullMethod string + InputData types.Map + type Handler struct + func NewHandler(stubStore StubStore, fileStorage fs.FileStorage) *Handler + func (h *Handler) Handle(w http.ResponseWriter, r *http.Request) + func (h *Handler) WithBodyStoreThreshold(v int) *Handler + func (h *Handler) WithNamespace(namespace string) *Handler + type IncomingQueryOption struct + Ids []int64 + Limit int + Namespace string + type IncomingRequest struct + Body []byte + CURL string + Header types.Map + ID int64 + Method string + Namespace string + StubID int64 + Tag string + URL string + func Capture(r *http.Request, bodyThreshold int) *IncomingRequest + func (i *IncomingRequest) Replay(ctx context.Context, server Server) (*http.Response, error) + func (i *IncomingRequest) ReserveRequest(ctx context.Context) (*http.Request, error) + func (i *IncomingRequest) WithNamespace(v string) *IncomingRequest + type IncomingRequests struct + Requests []*IncomingRequest + type LastUpdatedRecord struct + ID int64 + UpdatedAt time.Time + type LocalServer struct + func NewLocalServer() *LocalServer + func NewLocalServerWithReporter(t *testing.T) *LocalServer + func (s *LocalServer) Close(ctx context.Context) + func (s *LocalServer) Create(ctx context.Context, stubs ...*Stub) error + func (s *LocalServer) GetIncomingRequests(ctx context.Context, option *IncomingQueryOption) ([]*IncomingRequest, error) + func (s *LocalServer) GetURL(ctx context.Context) string + func (s *LocalServer) SetNamespace(v string) + func (s *LocalServer) UploadFile(ctx context.Context, fileID string, file []byte) (string, error) + func (s *LocalServer) WithNamespace(namespace string) *LocalServer + type Mode string + type Operator struct + Name OperatorName + Value interface{} + func (o Operator) IsValid() bool + func (o Operator) String() string + type OperatorName string + const OpContaining + const OpEmpty + const OpEndWith + const OpEqualTo + const OpLength + const OpNotContaining + const OpNotEmpty + const OpRegex + const OpStartWith + type Proto struct + CreatedAt time.Time + FileID string + ID int64 + Methods []string + Name string + Types []string + UpdatedAt time.Time + type Proxy struct + EnableRecord bool + TargetPath string + TargetURL string + func (r *Proxy) Scan(val interface{}) error + func (r Proxy) Value() (driver.Value, error) + type RemoteServer struct + func NewRemoteServer(rootURL string) *RemoteServer + func NewRemoteServerWithReporter(t *testing.T, rootURL string) *RemoteServer + func (s *RemoteServer) Close(ctx context.Context) + func (s *RemoteServer) Create(ctx context.Context, stubs ...*Stub) error + func (s *RemoteServer) GetIncomingRequests(ctx context.Context, option *IncomingQueryOption) ([]*IncomingRequest, error) + func (s *RemoteServer) GetURL(ctx context.Context) string + func (s *RemoteServer) ReplayOnShadowServer(ctx context.Context, options ...ReplayOptionFunc) error + func (s *RemoteServer) SetNamespace(v string) + func (s *RemoteServer) UploadFile(ctx context.Context, fileID string, fileBody []byte) (string, error) + func (s *RemoteServer) WithNamespace(namespace string) *RemoteServer + func (s *RemoteServer) WithShadowServer(server Server) *RemoteServer + type ReplayOption struct + type ReplayOptionFunc func(*ReplayOption) + func ReplayWithLimit(limit int) ReplayOptionFunc + func ReplayWithRequestID(ids ...int64) ReplayOptionFunc + type RequestMatching struct + Body []BodyOperator + Cookie []FieldOperator + Header []FieldOperator + Method string + Query []FieldOperator + URL []Operator + func (r *RequestMatching) Scan(val interface{}) error + func (r *RequestMatching) Validate(ctx context.Context) error + func (r RequestMatching) Value() (driver.Value, error) + type ResetQueryOption struct + Namespace string + Tag string + type Response struct + Body Body + BodyFile string + Cookies []Cookie + Error *ResponseError + Header map[string]string + StatusCode int + Template *Template + func HTMLResponse(html string) *Response + func JSONResponse(body interface{}) *Response + func NewResponse() *Response + func NewResponseFromHTTP(res *http.Response) *Response + func XMLResponse(body interface{}) *Response + func (r *Response) Clone() *Response + func (r *Response) LoadBodyFromFile(ctx context.Context, fileStorage fs.FileStorage) error + func (r *Response) LoadBodyFromTemplate(ctx context.Context, data *TemplateData) error + func (r *Response) Scan(val interface{}) error + func (r *Response) Validate(ctx context.Context) error + func (r *Response) WithBody(contentType string, body []byte) *Response + func (r *Response) WithCookie(name string, value string) *Response + func (r *Response) WithError(msg string, details ...*ErrorDetail) *Response + func (r *Response) WithFileBody(contentType string, fileID string) *Response + func (r *Response) WithHeader(name string, value string) *Response + func (r *Response) WithRedirect(url string) *Response + func (r *Response) WithStatusCode(s int) *Response + func (r *Response) WriteTo(ctx context.Context, w http.ResponseWriter) error + func (r Response) Value() (driver.Value, error) + type ResponseError struct + Details []*ErrorDetail + Message string + func (r *ResponseError) Clone() *ResponseError + type ResponseScript struct + Body string + Cookies []Cookie + Error *ResponseError + Headers map[string]string + StatusCode int + func (s *ResponseScript) AssignTo(r *Response) + type SchemaType string + const SchemaTypeJSON + const SchemaTypeYAML + type Server interface + Close func(ctx context.Context) + Create func(ctx context.Context, stubs ...*Stub) error + GetURL func(ctx context.Context) string + SetNamespace func(v string) + UploadFile func(ctx context.Context, fileID string, file []byte) (string, error) + type StatusStore interface + GetLastUpdatedProto func(ctx context.Context) (*LastUpdatedRecord, error) + GetLastUpdatedStub func(ctx context.Context, namespace string) (*LastUpdatedRecord, error) + type Stub struct + Active bool + CreatedAt time.Time + Description string + ID int64 + Namespace string + Protocol string + Proxy *Proxy + Request *RequestMatching + Response *Response + Settings StubSettings + Tag string + UpdatedAt time.Time + Weight int + func NewStub() *Stub + func SelectStubs(stubs []*Stub) *Stub + func (s *Stub) Clone() *Stub + func (s *Stub) For(method string, urlMatchingFuncs ...CreateOperator) *Stub + func (s *Stub) ForAny(urlMatchingFuncs ...CreateOperator) *Stub + func (s *Stub) ForGRPC(urlMatchingFuncs ...CreateOperator) *Stub + func (s *Stub) ForceJSON(ctx context.Context) string + func (s *Stub) HasTemplate() bool + func (s *Stub) IsReversed() bool + func (s *Stub) Send(ctx context.Context, server Server) error + func (s *Stub) ShouldDeactivateWhenMatched() *Stub + func (s *Stub) ShouldDelay(d time.Duration) *Stub + func (s *Stub) Validate(ctx context.Context) error + func (s *Stub) WillReturn(resp *Response) *Stub + func (s *Stub) WithCookie(name string, createFunc CreateOperator) *Stub + func (s *Stub) WithDescription(desc string) *Stub + func (s *Stub) WithEnableRecord(v bool) *Stub + func (s *Stub) WithHeader(name string, createFunc CreateOperator) *Stub + func (s *Stub) WithID(id int64) *Stub + func (s *Stub) WithInactive() *Stub + func (s *Stub) WithNamespace(namespace string) *Stub + func (s *Stub) WithQuery(name string, createFunc CreateOperator) *Stub + func (s *Stub) WithRequestBody(createFunc CreateBodyOperator) *Stub + func (s *Stub) WithTag(tag string) *Stub + func (s *Stub) WithTargetURL(url string) *Stub + func (s *Stub) WithWeight(weight int) *Stub + type StubMemory struct + func NewStubMemory() *StubMemory + func (db *StubMemory) Create(ctx context.Context, stubs ...*Stub) error + func (db *StubMemory) CreateIncomingRequest(ctx context.Context, r *IncomingRequest) error + func (db *StubMemory) CreateProto(ctx context.Context, protos ...*Proto) error + func (db *StubMemory) Delete(ctx context.Context, id int64) error + func (db *StubMemory) GetAll(_ context.Context, namespace string) ([]*Stub, error) + func (db *StubMemory) GetIncomingRequests(ctx context.Context, option *IncomingQueryOption) ([]*IncomingRequest, error) + func (db *StubMemory) GetProtos(ctx context.Context) ([]*Proto, error) + func (db *StubMemory) Reset(ctx context.Context, option *ResetQueryOption) error + type StubSettings struct + DeactivateWhenMatched bool + DelayDuration time.Duration + StoreVersion int + func (r *StubSettings) Clone() *StubSettings + func (r *StubSettings) Scan(val interface{}) error + func (r StubSettings) Value() (driver.Value, error) + type StubStore interface + Create func(ctx context.Context, stubs ...*Stub) error + CreateIncomingRequest func(ctx context.Context, r *IncomingRequest) error + CreateProto func(ctx context.Context, protos ...*Proto) error + Delete func(ctx context.Context, id int64) error + GetAll func(ctx context.Context, namespace string) ([]*Stub, error) + GetIncomingRequests func(ctx context.Context, option *IncomingQueryOption) ([]*IncomingRequest, error) + GetProtos func(ctx context.Context) ([]*Proto, error) + Reset func(ctx context.Context, option *ResetQueryOption) error + type Template struct + Script string + ScriptSchemaType SchemaType + func (t *Template) Execute(ctx context.Context, data *TemplateData) (*ResponseScript, error) + type TemplateData struct + Grpc *GrpcRequest + Request *http.Request + func (t *TemplateData) JSONBody() map[string]interface{}