Documentation ¶
Index ¶
- Constants
- Variables
- func Close() error
- func Configure(config Config)
- func EchoMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func GetEmbedAccessToken(ctx context.Context, req *embedaccesstoken.EmbedAccessTokenRequest) (string, error)
- func GinMiddleware(c *gin.Context)
- func Middleware(next http.Handler) http.Handler
- func MiddlewareController(r *http.Request) *controller
- func MiddlewareWithMux(mux Mux, next http.Handler) http.Handler
- func NewCaptureWriter(origResW http.ResponseWriter, maxBuffer int) *captureWriter
- type Config
- type DialerFunc
- type GRPCClient
- type MaskingOption
- func WithQueryStringMask(keys []string, masks ...string) MaskingOption
- func WithRequestCookieMask(cookies []string, masks ...string) MaskingOption
- func WithRequestFieldMaskNumber(fields []string, masks ...string) MaskingOption
- func WithRequestFieldMaskString(fields []string, masks ...string) MaskingOption
- func WithRequestHeaderMask(headers []string, masks ...string) MaskingOption
- func WithResponseCookieMask(cookies []string, masks ...string) MaskingOption
- func WithResponseFieldMaskNumber(fields []string, masks ...string) MaskingOption
- func WithResponseFieldMaskString(fields []string, masks ...string) MaskingOption
- func WithResponseHeaderMask(headers []string, masks ...string) MaskingOption
- type Mux
- type Speakeasy
- func (s *Speakeasy) Close() error
- func (s *Speakeasy) EchoMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func (s *Speakeasy) GetEmbedAccessToken(ctx context.Context, req *embedaccesstoken.EmbedAccessTokenRequest) (string, error)
- func (s *Speakeasy) GinMiddleware(c *gin.Context)
- func (s *Speakeasy) Middleware(next http.Handler) http.Handler
- func (s *Speakeasy) MiddlewareWithMux(mux Mux, next http.Handler) http.Handler
Constants ¶
const ( DefaultStringMask = "__masked__" DefaultNumberMask = "-12321" )
Variables ¶
var ( // ErrAPIKeyMissing is returned when the API Key is not provided at configuration time. ErrAPIKeyMissing = errors.New("API key is required") // ErrAPIIdMissing is returned when the Api ID is not provided at configuration time. ErrApiIDMissing = errors.New("ApiID is required") // ErrApiIDMalformed is returned when the Api ID is invalid. ErrApiIDMalformed = errors.New("ApiID is malformed") // ErrVersionIDMissing is returned when the Version ID is not provided at configuration time. ErrVersionIDMissing = errors.New("VersionID is required") // ErrVersionIDMalformed is returned when the Version ID is invalid. ErrVersionIDMalformed = errors.New("VersionID is malformed") )
var GRPCIngestTimeout = 1 * time.Second
Functions ¶
func Configure ¶
func Configure(config Config)
Configure allows you to configure the default instance of the Speakeasy SDK. Use this if you will use the same API Key for all connected APIs.
func EchoMiddleware ¶ added in v0.0.3
func EchoMiddleware(next echo.HandlerFunc) echo.HandlerFunc
EchoMiddleware setups up the default SDK instance to start capturing requests from the echo http framework.
func GetEmbedAccessToken ¶ added in v1.3.0
func GetEmbedAccessToken(ctx context.Context, req *embedaccesstoken.EmbedAccessTokenRequest) (string, error)
func GinMiddleware ¶ added in v0.0.3
GinMiddleware setups up the default SDK instance to start capturing requests from the gin http framework.
func Middleware ¶ added in v0.0.1
Middleware setups up the default SDK instance to start capturing requests from routers that support http.Handlers. Currently only gorilla/mux, go-chi/chi routers and the http.DefaultServerMux are supported for automatically capturing path hints. Otherwise path hints can be supplied by a handler through the speakeasy MiddlewareController.
func MiddlewareController ¶ added in v0.0.3
MiddlewareController will return the speakeasy middleware controller from the current request, if the current request is monitored by the speakeasy middleware.
func MiddlewareWithMux ¶ added in v1.7.0
MiddlewareWithMux setups up the default SDK instance to start capturing requests from routers based on the net/http ServeMux interface This should be used when not using the http.DefaultServeMux, such as when using a custom mux or something like DataDog's httptrace.NewServeMux().
func NewCaptureWriter ¶ added in v0.0.3
func NewCaptureWriter(origResW http.ResponseWriter, maxBuffer int) *captureWriter
Types ¶
type Config ¶
type Config struct { // APIKey is the API Key obtained from the Speakeasy platform for capturing requests to a particular workspace. APIKey string // ApiID is the ID of the Api to associate any requests captured by this instance of the SDK to. ApiID string // VersionID is the ID of the Api Version to associate any requests captured by this instance of the SDK to. VersionID string GRPCDialer func() func(context.Context, string) (net.Conn, error) }
Config provides configuration for the Speakeasy SDK.
type DialerFunc ¶ added in v1.3.0
type GRPCClient ¶ added in v1.3.0
type GRPCClient struct {
// contains filtered or unexported fields
}
func (*GRPCClient) GetEmbedAccessToken ¶ added in v1.3.0
func (c *GRPCClient) GetEmbedAccessToken(ctx context.Context, req *embedaccesstoken.EmbedAccessTokenRequest) (string, error)
func (*GRPCClient) SendToIngest ¶ added in v1.3.0
func (c *GRPCClient) SendToIngest(ctx context.Context, req *ingest.IngestRequest)
type MaskingOption ¶ added in v1.2.0
type MaskingOption func(c *controller)
func WithQueryStringMask ¶ added in v1.2.0
func WithQueryStringMask(keys []string, masks ...string) MaskingOption
WithQueryStringMask will mask the specified query strings with an optional mask string. If no mask is provided, the value will be masked with the default mask. If a single mask is provided, it will be used for all query strings. If the number of masks provided is equal to the number of query strings, masks will be used in order. Otherwise, the masks will be used in order until it they are exhausted. If the masks are exhausted, the default mask will be used. (defaults to "__masked__").
func WithRequestCookieMask ¶ added in v1.2.0
func WithRequestCookieMask(cookies []string, masks ...string) MaskingOption
WithRequestCookieMask will mask the specified request cookies with an optional mask string. If no mask is provided, the value will be masked with the default mask. If a single mask is provided, it will be used for all cookies. If the number of masks provided is equal to the number of cookies, masks will be used in order. Otherwise, the masks will be used in order until it they are exhausted. If the masks are exhausted, the default mask will be used. (defaults to "__masked__").
func WithRequestFieldMaskNumber ¶ added in v1.2.0
func WithRequestFieldMaskNumber(fields []string, masks ...string) MaskingOption
WithRequestFieldMaskNumber will mask the specified request body fields with an optional mask. Supports number fields only. Matches using regex. If no mask is provided, the value will be masked with the default mask. If a single mask is provided, it will be used for all fields. If the number of masks provided is equal to the number of fields, masks will be used in order. Otherwise, the masks will be used in order until it they are exhausted. If the masks are exhausted, the default mask will be used. (defaults to "-12321").
func WithRequestFieldMaskString ¶ added in v1.2.0
func WithRequestFieldMaskString(fields []string, masks ...string) MaskingOption
WithRequestFieldMaskString will mask the specified request body fields with an optional mask. Supports string fields only. Matches using regex. If no mask is provided, the value will be masked with the default mask. If a single mask is provided, it will be used for all fields. If the number of masks provided is equal to the number of fields, masks will be used in order. Otherwise, the masks will be used in order until it they are exhausted. If the masks are exhausted, the default mask will be used. (defaults to "__masked__").
func WithRequestHeaderMask ¶ added in v1.2.0
func WithRequestHeaderMask(headers []string, masks ...string) MaskingOption
WithRequestHeaderMask will mask the specified request headers with an optional mask string. If no mask is provided, the value will be masked with the default mask. If a single mask is provided, it will be used for all headers. If the number of masks provided is equal to the number of headers, masks will be used in order. Otherwise, the masks will be used in order until it they are exhausted. If the masks are exhausted, the default mask will be used. (defaults to "__masked__").
func WithResponseCookieMask ¶ added in v1.2.0
func WithResponseCookieMask(cookies []string, masks ...string) MaskingOption
WithResponseCookieMask will mask the specified response cookies with an optional mask string. If no mask is provided, the value will be masked with the default mask. If a single mask is provided, it will be used for all cookies. If the number of masks provided is equal to the number of cookies, masks will be used in order. Otherwise, the masks will be used in order until it they are exhausted. If the masks are exhausted, the default mask will be used. (defaults to "__masked__").
func WithResponseFieldMaskNumber ¶ added in v1.2.0
func WithResponseFieldMaskNumber(fields []string, masks ...string) MaskingOption
WithResponseFieldMaskNumber will mask the specified response body with an optional mask. Supports number fields only. Matches using regex. If no mask is provided, the value will be masked with the default mask. If a single mask is provided, it will be used for all fields. If the number of masks provided is equal to the number of fields, masks will be used in order. Otherwise, the masks will be used in order until it they are exhausted. If the masks are exhausted, the default mask will be used. (defaults to "-12321").
func WithResponseFieldMaskString ¶ added in v1.2.0
func WithResponseFieldMaskString(fields []string, masks ...string) MaskingOption
WithResponseFieldMaskString will mask the specified response body with an optional mask. Supports string only. Matches using regex. If no mask is provided, the value will be masked with the default mask. If a single mask is provided, it will be used for all fields. If the number of masks provided is equal to the number of fields, masks will be used in order. Otherwise, the masks will be used in order until it they are exhausted. If the masks are exhausted, the default mask will be used. (defaults to "__masked__").
func WithResponseHeaderMask ¶ added in v1.2.0
func WithResponseHeaderMask(headers []string, masks ...string) MaskingOption
WithResponseHeaderMask will mask the specified response headers with an optional mask string. If no mask is provided, the value will be masked with the default mask. If a single mask is provided, it will be used for all headers. If the number of masks provided is equal to the number of headers, masks will be used in order. Otherwise, the masks will be used in order until it they are exhausted. If the masks are exhausted, the default mask will be used. (defaults to "__masked__").
type Mux ¶ added in v1.7.0
Mux represents a router that conforms to the net/http ServeMux interface.
type Speakeasy ¶ added in v1.1.0
type Speakeasy struct {
// contains filtered or unexported fields
}
Speakeasy is the concrete type for the Speakeasy SDK. Don't instantiate this directly, use Configure() or New() instead.
func New ¶ added in v0.0.1
New creates a new instance of the Speakeasy SDK. This allows you to create multiple instances of the SDK for specifying different API Keys for different APIs.
func (*Speakeasy) EchoMiddleware ¶ added in v1.1.0
func (s *Speakeasy) EchoMiddleware(next echo.HandlerFunc) echo.HandlerFunc
EchoMiddleware setups the current instance of the SDK to start capturing requests from the echo http framework.
func (*Speakeasy) GetEmbedAccessToken ¶ added in v1.3.0
func (s *Speakeasy) GetEmbedAccessToken(ctx context.Context, req *embedaccesstoken.EmbedAccessTokenRequest) (string, error)
func (*Speakeasy) GinMiddleware ¶ added in v1.1.0
GinMiddleware setups the current instance of the SDK to start capturing requests from the gin http framework.
func (*Speakeasy) Middleware ¶ added in v1.1.0
Middleware setups the current instance of the SDK to start capturing requests from routers that support http.Handlers. Currently only gorilla/mux, go-chi/chi routers and the http.DefaultServerMux are supported for automatically capturing path hints. Otherwise path hints can be supplied by a handler through the speakeasy MiddlewareController.
func (*Speakeasy) MiddlewareWithMux ¶ added in v1.7.0
MiddlewareWithMux setups up the current instance of the SDK to start capturing requests from routers based on the net/http ServeMux interface This should be used when not using the http.DefaultServeMux, such as when using a custom mux or something like DataDog's httptrace.NewServeMux().