interceptor

package
v0.0.0-...-ec14ce0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthFunc = func(ctx context.Context) (context.Context, error) {
	authInfo, err := AuthInfoFromContext(ctx)
	if err != nil {
		return nil, status.Errorf(codes.Unauthenticated, "invalid auth info: %v", err)
	}

	key, err := EthAddrFromAuthInfo(authInfo)
	if err != nil {
		return nil, status.Errorf(codes.Unauthenticated, "invalid key: %v", err)
	}
	return EthAddrToContext(ctx, key), nil
}

AuthFunc default auth by ehtereum address.

Functions

func EthAddrFromAuthInfo

func EthAddrFromAuthInfo(authInfo EthAuthInfo) (common.Address, error)

EthAddrFromAuthInfo extracts eth addr from auth info.

func EthAddrFromContext

func EthAddrFromContext(ctx context.Context) (common.Address, error)

EthAddrFromContext extracts eth address from the given context.

func EthAddrToContext

func EthAddrToContext(ctx context.Context, address common.Address) context.Context

EthAddrToContext puts the given eth address to the context.

func Extract

func Extract(ctx context.Context) string

Extract takes a requestID from context.

func NewStreamAuthenticator

func NewStreamAuthenticator(authFunc grpc_auth.AuthFunc) grpc.StreamServerInterceptor

NewStreamAuthenticator Creates new stream interceptor to authenticate requests.

func NewStreamPanic

func NewStreamPanic() grpc.StreamServerInterceptor

NewStreamPanic Creates new stream interceptor to recover from panics.

func NewStreamSimpleTracer

func NewStreamSimpleTracer() grpc.StreamServerInterceptor

NewStreamSimpleTracer Creates new stream interceptor for tracing requests.

func NewStreamZapLogger

func NewStreamZapLogger(logger *zap.Logger) grpc.StreamServerInterceptor

NewStreamZapLogger Creates new stream interceptor for logging using zap.

func NewUnaryAuthenticator

func NewUnaryAuthenticator(authFunc grpc_auth.AuthFunc) grpc.UnaryServerInterceptor

NewUnaryAuthenticator Creates new unary interceptor to authenticate requests.

func NewUnaryPanic

func NewUnaryPanic() grpc.UnaryServerInterceptor

NewUnaryPanic Creates new unary interceptor to recover from panics.

func NewUnarySimpleTracer

func NewUnarySimpleTracer() grpc.UnaryServerInterceptor

NewUnarySimpleTracer Creates new unary interceptor for tracing requests.

func NewUnaryZapLogger

func NewUnaryZapLogger(logger *zap.Logger) grpc.UnaryServerInterceptor

NewUnaryZapLogger Creates new unary interceptor for logging using zap.

func ToContext

func ToContext(ctx context.Context, requestID string) context.Context

ToContext returns a context which knows its request ID.

Types

type EthAuthInfo

type EthAuthInfo interface {
	credentials.AuthInfo
	WalletAddress() common.Address
}

EthAuthInfo holds auth info containing ethereum address.

func AuthInfoFromContext

func AuthInfoFromContext(ctx context.Context) (EthAuthInfo, error)

AuthInfoFromContext extracts eth address from the context.

type Frame

type Frame uintptr

Frame represents a program counter inside a Stack frame.

func (Frame) Format

func (f Frame) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   path of source file relative to the compile time GOPATH
%+v   equivalent to %+s:%d

nolint

type Stack

type Stack []uintptr

Stack represents a Stack of program counters.

func Callers

func Callers() *Stack

Callers returns the Stacktrace.

func (*Stack) Format

func (s *Stack) Format(st fmt.State, verb rune)

Format formats the stacktrace.

type StackTrace

type StackTrace []Frame

StackTrace is Stack of Frames from innermost (newest) to outermost (oldest).

func (StackTrace) Format

func (st StackTrace) Format(s fmt.State, verb rune)

Format formats the Stack of Frames according to the fmt.Formatter interface.

%s	lists source files for each Frame in the Stack
%v	lists the source file and line number for each Frame in the Stack

Format accepts flags that alter the printing of some verbs, as follows:

%+v   Prints filename, function, and line number for each Frame in the Stack.

nolint

Jump to

Keyboard shortcuts

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