oapi

package
v0.0.0-...-8af0910 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReqTooLargeError = echo.NewHTTPError(
	http.StatusRequestEntityTooLarge, "request is too large")

Functions

func AttachDefenseAgainstDarkArts

func AttachDefenseAgainstDarkArts(e *echo.Echo, maxRequestSize int, timeout time.Duration)

Attach middleware to Echo to prevent slow-loris attacks and DDoS-es by extremely large requests.

func GetZapLoggerFromEchoLogger

func GetZapLoggerFromEchoLogger(logger echo.Logger) *zap.Logger

func LimitReaderWithErr

func LimitReaderWithErr(r io.ReadCloser, n int64, err error) io.ReadCloser

LimitReader returns a Reader that reads from r but stops with an error after n bytes. The underlying implementation is a *LimitedReaderWithErr.

func NewEchoTargetedHttpClient

func NewEchoTargetedHttpClient(ec *echo.Echo) http.Client

func OapiRequestValidatorWithMetrics

func OapiRequestValidatorWithMetrics(swagger *openapi3.Swagger, apiPath string,
	validator AuthValidatorFunc) echo.MiddlewareFunc

Create middleware to validate requests against OAPI3 specification. Additionally this middleware initialized the metric context for the request with appropriate metrics and submits this segment at the end of the request.

Each request gets annotated with the following metrics: Success: 0 or 1 (count). 0 if the request errors out or panics. Fault: 0 or 1 (count). 1 if the request panics. Time: request duration (time)

func TracingAndLoggingMiddlewareHook

func TracingAndLoggingMiddlewareHook(opts TracingAndMetricsOptions) echo.MiddlewareFunc

Insert middleware responsible for logging, metrics and tracing

Types

type AuthValidatorFunc

type AuthValidatorFunc func(e echo.Context, input *openapi3filter.AuthenticationInput) error

type DirectEchoTransport

type DirectEchoTransport struct {
	Echo *echo.Echo
}

func (*DirectEchoTransport) RoundTrip

func (f *DirectEchoTransport) RoundTrip(req *http.Request) (*http.Response, error)

type LimitedReaderWithErr

type LimitedReaderWithErr struct {
	Reader    io.ReadCloser // underlying reader
	BytesLeft int64         // max bytes remaining
	Error     error         // the error to return in case of too much data
}

A LimitedReaderWithErr reads from Reader but limits the amount of data returned to just BytesLeft bytes. Each call to Read updates BytesLeft to reflect the new amount remaining. Read returns error when BytesLeft <= 0 or when the underlying Reader returns EOF.

func (*LimitedReaderWithErr) Close

func (l *LimitedReaderWithErr) Close() error

func (*LimitedReaderWithErr) Read

func (l *LimitedReaderWithErr) Read(p []byte) (n int, err error)

type TracingAndMetricsOptions

type TracingAndMetricsOptions struct {
	DebugMode  bool
	SampleRate *float64
	Statsd     statsd.ClientInterface

	Logger *zap.Logger
}

func (*TracingAndMetricsOptions) Validate

func (t *TracingAndMetricsOptions) Validate()

type ZapLoggerWrapper

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

func NewLoggerWrapper

func NewLoggerWrapper(zLogger *zap.Logger) *ZapLoggerWrapper

Create a new wrapper for an Echo logger, imbued with a contextualized Zap logger

func (*ZapLoggerWrapper) Debug

func (l *ZapLoggerWrapper) Debug(i ...interface{})

func (*ZapLoggerWrapper) Debugf

func (l *ZapLoggerWrapper) Debugf(format string, args ...interface{})

func (*ZapLoggerWrapper) Debugj

func (l *ZapLoggerWrapper) Debugj(j log.JSON)

func (*ZapLoggerWrapper) Error

func (l *ZapLoggerWrapper) Error(i ...interface{})

func (*ZapLoggerWrapper) Errorf

func (l *ZapLoggerWrapper) Errorf(format string, args ...interface{})

func (*ZapLoggerWrapper) Errorj

func (l *ZapLoggerWrapper) Errorj(j log.JSON)

func (*ZapLoggerWrapper) Fatal

func (l *ZapLoggerWrapper) Fatal(i ...interface{})

func (*ZapLoggerWrapper) Fatalf

func (l *ZapLoggerWrapper) Fatalf(format string, args ...interface{})

func (*ZapLoggerWrapper) Fatalj

func (l *ZapLoggerWrapper) Fatalj(j log.JSON)

func (*ZapLoggerWrapper) Info

func (l *ZapLoggerWrapper) Info(i ...interface{})

func (*ZapLoggerWrapper) Infof

func (l *ZapLoggerWrapper) Infof(format string, args ...interface{})

func (*ZapLoggerWrapper) Infoj

func (l *ZapLoggerWrapper) Infoj(j log.JSON)

func (*ZapLoggerWrapper) Level

func (l *ZapLoggerWrapper) Level() log.Lvl

func (*ZapLoggerWrapper) Output

func (l *ZapLoggerWrapper) Output() io.Writer

func (*ZapLoggerWrapper) Panic

func (l *ZapLoggerWrapper) Panic(i ...interface{})

func (*ZapLoggerWrapper) Panicf

func (l *ZapLoggerWrapper) Panicf(format string, args ...interface{})

func (*ZapLoggerWrapper) Panicj

func (l *ZapLoggerWrapper) Panicj(j log.JSON)

func (*ZapLoggerWrapper) Prefix

func (l *ZapLoggerWrapper) Prefix() string

func (*ZapLoggerWrapper) Print

func (l *ZapLoggerWrapper) Print(i ...interface{})

func (*ZapLoggerWrapper) Printf

func (l *ZapLoggerWrapper) Printf(format string, args ...interface{})

func (*ZapLoggerWrapper) Printj

func (l *ZapLoggerWrapper) Printj(j log.JSON)

func (*ZapLoggerWrapper) SetHeader

func (l *ZapLoggerWrapper) SetHeader(h string)

func (*ZapLoggerWrapper) SetLevel

func (l *ZapLoggerWrapper) SetLevel(lvl log.Lvl)

func (ZapLoggerWrapper) SetOutput

func (l ZapLoggerWrapper) SetOutput(w io.Writer)

func (*ZapLoggerWrapper) SetPrefix

func (l *ZapLoggerWrapper) SetPrefix(s string)

func (*ZapLoggerWrapper) Warn

func (l *ZapLoggerWrapper) Warn(i ...interface{})

func (*ZapLoggerWrapper) Warnf

func (l *ZapLoggerWrapper) Warnf(format string, args ...interface{})

func (*ZapLoggerWrapper) Warnj

func (l *ZapLoggerWrapper) Warnj(j log.JSON)

Jump to

Keyboard shortcuts

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