middleware

package
v0.0.0-...-765b6f4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestFromServerContext

func RequestFromServerContext(ctx context.Context) (*http.Request, bool)

func SetRequest

func SetRequest(ctx context.Context, req *http.Request) context.Context

Types

type Context

type Context struct {
	context.Context
	Kind      Kind
	Method    string
	Path      string
	ReqHeader Header
	ResHeader Header
	Payload   any
}

func NewGRPCContext

func NewGRPCContext(ctx context.Context, method string, req any) *Context

func NewHTTPContext

func NewHTTPContext(req *http.Request) *Context

type Handler

type Handler func(ctx *Context) (any, error)
type Header map[string][]string

func (Header) Add

func (h Header) Add(key string, vals ...string)

func (Header) Copy

func (h Header) Copy() Header

func (Header) Get

func (h Header) Get(key string) string

func (Header) Keys

func (h Header) Keys() []string

func (Header) Len

func (h Header) Len() int

func (Header) Set

func (h Header) Set(key string, vals ...string)

func (Header) Values

func (h Header) Values(key string) []string

type Kind

type Kind string
const (
	KindHTTP Kind = "HTTP"
	KindGRPC Kind = "GRPC"
)

type Middleware

type Middleware func(next Handler) Handler

func Chain

func Chain(middlewares ...Middleware) Middleware

func (Middleware) Append

func (m Middleware) Append(children ...Middleware) Middleware

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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