middleware

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package middleware contains middlewares for gRPC unknown handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap added in v0.3.0

func Wrap(base grpc.StreamHandler, mws ...Middleware) grpc.StreamHandler

Wrap is a chain of middlewares.

Types

type Middleware

type Middleware func(grpc.StreamHandler) grpc.StreamHandler

Middleware is a function that intercepts the execution of a gRPC handler.

func AppInfo

func AppInfo(app, author, version string) Middleware

AppInfo adds the app info to the header metadata.

func Chain

func Chain(mws ...Middleware) Middleware

Chain chains the middlewares.

func Log

func Log(debug bool, skipPrefixes ...string) Middleware

Log logs the gRPC requests.

func Maybe added in v0.3.0

func Maybe(apply bool, mw Middleware) Middleware

Maybe is a middleware that conditionally applies the given middleware.

func PassMetadata added in v0.3.0

func PassMetadata() Middleware

PassMetadata passes the incoming metadata into outgoing metadata.

func Recoverer

func Recoverer() Middleware

Recoverer is a middleware that recovers from panics, logs the panic and returns a gRPC error if possible.

type Reflector added in v0.3.0

type Reflector struct {
	Logger        *slog.Logger
	UpstreamsFunc func() []discovery.Upstream
}

Reflector serves the reflection across multiple upstreams, by upstreaming the first request to each one and finding the one that doesn't respond a NotFound status and then piping the response back to the client.

func (Reflector) Middleware added in v0.3.0

func (r Reflector) Middleware(next grpc.StreamHandler) grpc.StreamHandler

Middleware returns a middleware that reflects the request to the upstreams.

type SRIClient added in v0.3.0

SRIClient is a shorthand for a server reflection stream client.

Jump to

Keyboard shortcuts

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