middleware

package
v0.7.0-rc9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: MPL-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const (
	GRPCAuthMetadataKey    = "grpc-auth"
	GitProviderTokenHeader = "Git-Provider-Token"
)

Variables

View Source
var RequestErrorText = "request error"
View Source
var RequestOkText = "request success"
View Source
var ServerErrorText = "server error"

Functions

func ContextWithGRPCAuth

func ContextWithGRPCAuth(ctx context.Context, token string) context.Context

func ExtractProviderToken

func ExtractProviderToken(ctx context.Context) (*oauth2.Token, error)

Get the token from request context.

func WithGrpcErrorLogging

func WithGrpcErrorLogging(log logr.Logger) runtime.ServeMuxOption

WithGrpcErrorLogging logs errors returned from server RPC handlers. Our errors happen in gRPC land, so we cannot introspect into the content of the error message in the WithLogging http.Handler. Normal gRPC middleware was not working for this: https://github.com/grpc-ecosystem/grpc-gateway/issues/1043

func WithLogging

func WithLogging(log logr.Logger, mux *runtime.ServeMux) http.Handler

WithLogging adds basic logging for HTTP requests. Note that this accepts a grpc-gateway ServeMux instead of an http.Handler.

func WithProviderToken

func WithProviderToken(jwtClient auth.JWTClient, h http.Handler, log logr.Logger) http.Handler

Injects the token into the request context to be retrieved later. Use the ExtractToken func inside the server handler where appropriate.

Types

This section is empty.

Jump to

Keyboard shortcuts

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