internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source

Variables

View Source
var MOCKAPIC_CERT_DIRECTORY = os.Getenv("MOCKAPIC_CERT")
View Source
var MOCKAPIC_CERT_FILENAME = "mockapic.crt"
View Source
var MOCKAPIC_HOME = os.Getenv("MOCKAPIC_HOME")
View Source
var MOCKAPIC_PEM_FILENAME = "mockapic.key"
View Source
var MOCKAPIC_PORT = os.Getenv("MOCKAPIC_PORT")
View Source
var MOCKAPIC_REQUEST = func() string {
	return MOCKAPIC_HOME + "/requests"
}
View Source
var MOCKAPIC_REQ_MAX_LIMIT = stringsutil.Int(os.Getenv("MOCKAPIC_REQ_MAX_LIMIT"), -1)
View Source
var MOCKAPIC_REQ_PREDEFINED_FILE = func() string {
	return MOCKAPIC_HOME + "/mockapic.json"
}
View Source
var MOCKAPIC_SSL = stringsutil.Bool(os.Getenv("MOCKAPIC_SSL"))

Functions

This section is empty.

Types

type Mock

type Mock struct {
	// contains filtered or unexported fields
}

func NewMock

func NewMock(workingDirectory string, predefinedMockedRequests []PredefinedMockedRequest, logger logsutil.Logger) Mock

func (Mock) Clean

func (m Mock) Clean(maxLimit int) (int, error)

Clean removes the x (nb mocked request - max limit) last requests.

func (Mock) Get

func (m Mock) Get(mockId string) (*MockedRequest, error)

Get finds the mocked request by {mockId} value on the storage or in the predefined requests.

func (Mock) List

func (m Mock) List() ([]MockedRequestLight, error)

List gets all mocked requests on the storage and the predefined requests.

func (Mock) New

func (m Mock) New(reqParams map[string][]string, reqBody []byte) (*string, error)

New creates a new mocked request and returns the new identifier.

type MockedRequest

type MockedRequest struct {
	MockedRequestLight
	Body   string `json:"body,omitempty"`
	Body64 []byte `json:"body64,omitempty"`
}

func (MockedRequest) Equals

func (m MockedRequest) Equals(arg MockedRequest) bool

Equals returns true if the two requests are equal

type MockedRequestHeader

type MockedRequestHeader struct {
	Status      int               `json:"status,omitempty"`
	ContentType string            `json:"contentType,omitempty"`
	Charset     string            `json:"charset,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
}

type MockedRequestLight

type MockedRequestLight struct {
	Id        string `json:"id,omitempty"`
	CreatedAt string `json:"createdAt,omitempty"`
	MockedRequestHeader
}

type Mocker

type Mocker interface {
	Get(mockId string) (*MockedRequest, error)
	List() ([]MockedRequestLight, error)
	New(params map[string][]string, body []byte) (*string, error)
	Clean(maxLimit int) (int, error)
}

type PredefinedMockedRequest

type PredefinedMockedRequest struct {
	MockedRequest
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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