middleware

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 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, h http.Handler) http.Handler

WithLogging adds basic logging for HTTP requests.

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