middleware

package
v0.0.0-...-265a0a8 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Error500ResponseEnvName = "DATABRICKS_MOCK_API_ERROR_500_PROBABILITY"

Error500ResponseEnvName is the name of the env var for specifying the probability of returning a 500 response. E.g. 20 => 20% chance of returning a 500 response

View Source
const ErrorSinkHoleResponseEnvName = "DATABRICKS_MOCK_API_ERROR_SINKHOLE_PROBABILITY"

ErrorSinkHoleResponseEnvName is name of the env var for specifying the probability of a sink-hole response. A sink-hole response is a request that writes nothing as part of the response for an extended period (5 minutes) and holds open the connection during that time. E.g. 20 => 20% chance of returning a sink-hole response

View Source
const ErrorXMLResponseEnvName = "DATABRICKS_MOCK_API_ERROR_XML_RESPONSE_PROBABILITY"

ErrorXMLResponseEnvName is the name of the env var for specifying status code of 200 but with XML body

View Source
const LatencyFastRequestMaxEnvName = "DATABRICKS_MOCK_API_LATENCY_MILLISECONDS_FAST_REQUEST_MAX"

LatencyFastRequestMaxEnvName is the name of the env var for the max latency setting of a fast request Eg: Get request

View Source
const LatencyFastRequestMinEnvName = "DATABRICKS_MOCK_API_LATENCY_MILLISECONDS_FAST_REQUEST_MIN"

LatencyFastRequestMinEnvName is the name of the env var for the min latency setting of a fast request Eg: Get request

View Source
const LatencySlowRequestMaxEnvName = "DATABRICKS_MOCK_API_LATENCY_MILLISECONDS_SLOW_REQUEST_MAX"

LatencySlowRequestMaxEnvName is the name of the env var for the max latency setting of a slow request Eg: Post request

View Source
const LatencySlowRequestMinEnvName = "DATABRICKS_MOCK_API_LATENCY_MILLISECONDS_SLOW_REQUEST_MIN"

LatencySlowRequestMinEnvName is the name of the env var for the min latency setting of a slow request Eg: Post request

View Source
const RateLimitEnvName = "DATABRICKS_MOCK_API_RATE_LIMIT"

RateLimitEnvName is the name of the env var for the rate limit setting

Variables

This section is empty.

Functions

func Add

func Add(h http.Handler, middleware ...func(http.Handler) http.Handler) http.Handler

Add applies a set of middleware to a http.Handler. Middleware is applied so that it executes in the order specified. E.g. middleware.Add(h, mw1, mw2) is equivalent to mw2(mw1(h))

func AddLatency

func AddLatency(next http.Handler) http.Handler

AddLatency applies random latency to the request

func ErrorResponse

func ErrorResponse(handler http.Handler) http.Handler

ErrorResponse injects error behavior based on config

func GetErrorSinkHoleDuration

func GetErrorSinkHoleDuration() time.Duration

GetErrorSinkHoleDuration returns the duration used for sink-hole requests

func RateLimit

func RateLimit(handler http.Handler) http.Handler

RateLimit applies rate-limiting to the requests

func SetErrorSinkHoleDuration

func SetErrorSinkHoleDuration(duration time.Duration)

SetErrorSinkHoleDuration sets the duration used for sink-hole requests

Types

This section is empty.

Jump to

Keyboard shortcuts

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