middleware

package
v0.0.0-...-9162fdb Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-2.0 Imports: 6 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LogMiddleware = func(name string) endpoint.Middleware {
		return func(next endpoint.Endpoint) endpoint.Endpoint {
			return func(ctx context.Context, req, resp interface{}) error {
				err := next(ctx, req, resp)
				log.CtxInfo(ctx, "[%s RPC Request] req=%s, resp=%s, err=%v", name, util.JSONF(req), util.JSONF(resp), err)
				return err
			}
		}
	}
	EnvironmentMiddleware = func(next endpoint.Endpoint) endpoint.Endpoint {
		return func(ctx context.Context, req, resp interface{}) error {
			md, _ := metadata.FromIncomingContext(ctx)
			if env := md.Get(consts.EnvHeader); len(env) != 0 && env[0] != "" {
				ctx = metadata.AppendToOutgoingContext(ctx, consts.EnvHeader, env[0])
			}
			return next(ctx, req, resp)
		}
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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