mockery

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndpointTypeNormal = "normal"
	EndpointTypeRegex  = "regex"
)

Variables

View Source
var (
	ErrEndpointNotFound = fmt.Errorf("no matching endpoint found")
)

Functions

func IsJSON

func IsJSON(str string) bool

Types

type Config

type Config struct {
	ListenIP   string     `json:"listen_ip"`
	ListenPort int        `json:"listen_port"`
	ProxyPass  string     `json:"proxy_pass"`
	Endpoints  []Endpoint `json:"endpoints"`
}

func OpenConfigFile

func OpenConfigFile(path string) (Config, error)

type Endpoint

type Endpoint struct {
	Uri          string     `json:"uri"`
	Type         string     `json:"type"`
	Method       string     `json:"method"`
	ResponseCode int        `json:"response_code"`
	Template     string     `json:"template"`
	Variables    []Variable `json:"variables"`
}

type MockHandler

type MockHandler struct {
	Config Config
}

func (MockHandler) MatchEndpoint

func (s MockHandler) MatchEndpoint(r *http.Request) (Endpoint, error)

func (MockHandler) RenderTemplateResponse

func (s MockHandler) RenderTemplateResponse(e Endpoint) (string, error)

func (MockHandler) ServeHTTP

func (s MockHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (MockHandler) ValidateConfig

func (s MockHandler) ValidateConfig() error

type Variable

type Variable struct {
	Name   string `json:"name"`
	EnvVar string `json:"env_var"`
	Value  string `json:"value"`
}

Jump to

Keyboard shortcuts

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