Back to godoc.org

Package middleware

v0.0.6
Latest Go to latest

The highest tagged major version is .

Published: May 11, 2020 | License: MIT | Module: github.com/neoxelox/microservice-template

Index

Constants

const (
	// NEWRELIC_TXN defines the context key used to save newrelic transaction
	NEWRELIC_TXN = "newrelic-txn"
)

Variables

var (
	// DefaultLogrusConfig is the default Logrus middleware config.
	DefaultLogrusConfig = LogrusConfig{
		FieldMap: map[string]string{
			"id":            "@id",
			"remote_ip":     "@remote_ip",
			"uri":           "@uri",
			"host":          "@host",
			"method":        "@method",
			"status":        "@status",
			"latency":       "@latency",
			"latency_human": "@latency_human",
			"bytes_in":      "@bytes_in",
			"bytes_out":     "@bytes_out",
		},
		Logger:  logrus.StandardLogger(),
		Skipper: mw.DefaultSkipper,
	}
)

func Logrus

func Logrus() echo.MiddlewareFunc

Logrus returns a middleware that logs HTTP requests.

func LogrusWithConfig

func LogrusWithConfig(config LogrusConfig) echo.MiddlewareFunc

LogrusWithConfig returns a Logrus middleware with config.

func NewRelic

func NewRelic(appName string, licenseKey string) echo.MiddlewareFunc

NewRelic returns a middleware that collect request data for NewRelic

func NewRelicWithApplication

func NewRelicWithApplication(app nr.Application) echo.MiddlewareFunc

NewRelicWithApplication returns a NewRelic middleware with application.

type Application

type Application struct{}

func (*Application) RecordCustomEvent

func (app *Application) RecordCustomEvent(eventType string, params map[string]interface{}) error

func (*Application) RecordCustomMetric

func (app *Application) RecordCustomMetric(name string, value float64) error

func (*Application) Shutdown

func (app *Application) Shutdown(timeout time.Duration)

func (*Application) StartTransaction

func (app *Application) StartTransaction(name string, w http.ResponseWriter, r *http.Request) nr.Transaction

func (*Application) WaitForConnection

func (app *Application) WaitForConnection(timeout time.Duration) error

type DistributedTracePayload

type DistributedTracePayload struct{}

func (*DistributedTracePayload) HTTPSafe

func (dt *DistributedTracePayload) HTTPSafe() string

func (*DistributedTracePayload) Text

func (dt *DistributedTracePayload) Text() string

type LogrusConfig

type LogrusConfig struct {
	// FieldMap set a list of fields with tags
	//
	// Tags to constructed the logger fields.
	//
	// - @id (Request ID)
	// - @remote_ip
	// - @uri
	// - @host
	// - @method
	// - @path
	// - @referer
	// - @user_agent
	// - @status
	// - @latency (In nanoseconds)
	// - @latency_human (Human readable)
	// - @bytes_in (Bytes received)
	// - @bytes_out (Bytes sent)
	// - @header:<NAME>
	// - @query:<NAME>
	// - @form:<NAME>
	// - @cookie:<NAME>
	FieldMap map[string]string

	// Logger it is a logrus logger
	Logger logrus.FieldLogger

	// Skipper defines a function to skip middleware.
	Skipper mw.Skipper
}

LogrusConfig defines the config for Logrus middleware.

type MockLogger

type MockLogger struct{}

func (*MockLogger) Debug

func (m *MockLogger) Debug(i ...interface{})

func (*MockLogger) Debugf

func (m *MockLogger) Debugf(format string, args ...interface{})

func (*MockLogger) Debugj

func (m *MockLogger) Debugj(j log.JSON)

func (*MockLogger) Error

func (m *MockLogger) Error(i ...interface{})

func (*MockLogger) Errorf

func (m *MockLogger) Errorf(format string, args ...interface{})

func (*MockLogger) Errorj

func (m *MockLogger) Errorj(j log.JSON)

func (*MockLogger) Fatal

func (m *MockLogger) Fatal(i ...interface{})

func (*MockLogger) Fatalf

func (m *MockLogger) Fatalf(format string, args ...interface{})

func (*MockLogger) Fatalj

func (m *MockLogger) Fatalj(j log.JSON)

func (*MockLogger) Info

func (m *MockLogger) Info(i ...interface{})

func (*MockLogger) Infof

func (m *MockLogger) Infof(format string, args ...interface{})

func (*MockLogger) Infoj

func (m *MockLogger) Infoj(j log.JSON)

func (*MockLogger) Level

func (m *MockLogger) Level() log.Lvl

func (*MockLogger) Output

func (m *MockLogger) Output() io.Writer

func (*MockLogger) Panic

func (m *MockLogger) Panic(i ...interface{})

func (*MockLogger) Panicf

func (m *MockLogger) Panicf(format string, args ...interface{})

func (*MockLogger) Panicj

func (m *MockLogger) Panicj(j log.JSON)

func (*MockLogger) Prefix

func (m *MockLogger) Prefix() string

func (*MockLogger) Print

func (m *MockLogger) Print(i ...interface{})

func (*MockLogger) Printf

func (m *MockLogger) Printf(format string, args ...interface{})

func (*MockLogger) Printj

func (m *MockLogger) Printj(j log.JSON)

func (*MockLogger) SetHeader

func (m *MockLogger) SetHeader(h string)

func (*MockLogger) SetLevel

func (m *MockLogger) SetLevel(v log.Lvl)

func (*MockLogger) SetOutput

func (m *MockLogger) SetOutput(w io.Writer)

func (*MockLogger) SetPrefix

func (m *MockLogger) SetPrefix(p string)

func (*MockLogger) Warn

func (m *MockLogger) Warn(i ...interface{})

func (*MockLogger) Warnf

func (m *MockLogger) Warnf(format string, args ...interface{})

func (*MockLogger) Warnj

func (m *MockLogger) Warnj(j log.JSON)

type Transaction

type Transaction struct {
	http.ResponseWriter
	Name string
}

func (*Transaction) AcceptDistributedTracePayload

func (tn *Transaction) AcceptDistributedTracePayload(t nr.TransportType, payload interface{}) error

func (*Transaction) AddAttribute

func (tn *Transaction) AddAttribute(key string, value interface{}) error

func (*Transaction) Application

func (tn *Transaction) Application() nr.Application

func (*Transaction) BrowserTimingHeader

func (tn *Transaction) BrowserTimingHeader() (*nr.BrowserTimingHeader, error)

func (*Transaction) CreateDistributedTracePayload

func (tn *Transaction) CreateDistributedTracePayload() nr.DistributedTracePayload

func (*Transaction) End

func (tn *Transaction) End() error

func (*Transaction) GetLinkingMetadata

func (tn *Transaction) GetLinkingMetadata() nr.LinkingMetadata

func (*Transaction) GetTraceMetadata

func (tn *Transaction) GetTraceMetadata() nr.TraceMetadata

func (*Transaction) Ignore

func (tn *Transaction) Ignore() error

func (*Transaction) IsSampled

func (tn *Transaction) IsSampled() bool

func (*Transaction) NewGoroutine

func (tn *Transaction) NewGoroutine() nr.Transaction

func (*Transaction) NoticeError

func (tn *Transaction) NoticeError(err error) error

func (*Transaction) SetName

func (tn *Transaction) SetName(name string) error

func (*Transaction) SetWebRequest

func (tn *Transaction) SetWebRequest(nr.WebRequest) error

func (*Transaction) SetWebResponse

func (tn *Transaction) SetWebResponse(http.ResponseWriter) nr.Transaction

func (*Transaction) StartSegmentNow

func (tn *Transaction) StartSegmentNow() nr.SegmentStartTime

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier