fake

package
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	R = NewRecords()
)
View Source
var (
	Service *gin.Engine
)

Functions

func Func added in v0.2.5

func Func(method string, path string, f func(ctx *gin.Context)) error

Func fakes method and path with a custom func

func JSON added in v0.2.5

func JSON(method string, path string, response map[string]any, statusCode int) error

JSON fakes for method, path, response and status code

func RecordKey added in v0.2.5

func RecordKey(method, path string) string

Types

type CustomResponseWriter added in v0.2.5

type CustomResponseWriter struct {
	gin.ResponseWriter
	// contains filtered or unexported fields
}

CustomResponseWriter wraps gin.ResponseWriter to capture response data

func (*CustomResponseWriter) Write added in v0.2.5

func (w *CustomResponseWriter) Write(data []byte) (int, error)

Write captures response data

type Input

type Input struct {
	Port int     `toml:"port" validate:"required"`
	Out  *Output `toml:"out"`
}

type Output

type Output struct {
	BaseURLHost   string `toml:"base_url_host"`
	BaseURLDocker string `toml:"base_url_docker"`
}

func NewFakeDataProvider

func NewFakeDataProvider(in *Input) (*Output, error)

NewFakeDataProvider creates new fake data provider

type Record added in v0.2.5

type Record struct {
	Method  string      `json:"method"`
	Path    string      `json:"path"`
	Headers http.Header `json:"headers"`
	ReqBody string      `json:"req_body"`
	ResBody string      `json:"res_body"`
	Status  int         `json:"status"`
}

Record is a request and response data

type Records added in v0.2.5

type Records struct {
	Data map[string][]*Record
}

func NewRecords added in v0.2.5

func NewRecords() *Records

func (*Records) Get added in v0.2.5

func (r *Records) Get(method, path string) ([]*Record, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL