Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidResponseFormat = fmt.Errorf("invalid response format")
Functions ¶
func RegisterEndpoint ¶
func RegisterEndpoint[T any](fm *Mux, endpointCfg EndpointConfig) error
RegisterEndpoint registers a new endpoint with a specific configuration for a given response type
Types ¶
type Config ¶
type Config struct {
FakeDataFunc FakeDataFunc
}
type EndpointConfig ¶
type EndpointConfig struct {
Method string
Path string
MinLatency time.Duration
MaxLatency time.Duration
FakeDataFunc FakeDataFunc
ResponseFormat ResponseFormat
ListResponseConfig *ListResponseConfig
ErrorResponseConfig *ErrorResponseConfig
}
func (EndpointConfig) Validate ¶
func (e EndpointConfig) Validate() error
type ErrorResponse ¶
type ErrorResponse struct {
StatusCode int
Response interface{}
ResponseFormat ResponseFormat
}
type ErrorResponseConfig ¶
type ErrorResponseConfig struct {
Frequency float64
Responses []ErrorResponse
}
func (ErrorResponseConfig) Validate ¶
func (e ErrorResponseConfig) Validate() error
type FakeDataFunc ¶
type FakeDataFunc func(v interface{}) error
FakeDataFunc is a function that generates fake data for a given type
type ListResponseConfig ¶
func (ListResponseConfig) Validate ¶
func (l ListResponseConfig) Validate() error
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
type ResponseFormat ¶
type ResponseFormat string
const ( JSON ResponseFormat = "json" Bytes ResponseFormat = "bytes" )
Click to show internal directories.
Click to hide internal directories.