middleware

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

*

@author: taco
@Date: 2023/9/27
@Time: 10:16

*

Index

Constants

This section is empty.

Variables

View Source
var File_result_proto protoreflect.FileDescriptor

Functions

func GetAccessToken

func GetAccessToken(headAuthorization []string) string

func JwtStreamInterceptor

func JwtStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func RbacStreamInterceptor

func RbacStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func ReturnProtoMsg

func ReturnProtoMsg(result CommonResponse, method string) (proto.Message, error)

Types

type CommonData

type CommonData struct {
	RequestID string      `json:"requestId"`
	Data      interface{} `json:"data"`
}

type CommonResponse

type CommonResponse struct {
	Code int32  `json:"code,omitempty"`
	Msg  string `json:"msg,omitempty"`
	Data any    `json:"data,omitempty"`
}

type Config

type Config struct {
	SvcName string
	Redis   *redis.Redis
	Rbac    *casbin.Enforcer
}

type JwtVerifyMiddleware

type JwtVerifyMiddleware struct {
	SvcName string
	Redis   *redis.Redis
	Rbac    *casbin.Enforcer
}

func NewJwtVerifyMiddleware

func NewJwtVerifyMiddleware(name string, rdb *redis.Redis, rbac *casbin.Enforcer) *JwtVerifyMiddleware

func (*JwtVerifyMiddleware) Handle

type MiddleContext

type MiddleContext struct {
	// note: 中间件上下文
	//Dao   *dao.Dao
	SvcName string
	Redis   *redis.Redis
	Rbac    *casbin.Enforcer
}

func NewMiddlewareContext

func NewMiddlewareContext(in Config) *MiddleContext

func (*MiddleContext) JwtUnaryInterceptor

func (SvcCtx *MiddleContext) JwtUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

func (*MiddleContext) RbacUnaryInterceptor

func (SvcCtx *MiddleContext) RbacUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

type ParseAccessKeyMiddleware

type ParseAccessKeyMiddleware struct {
}

func NewParseAccessKeyMiddleware

func NewParseAccessKeyMiddleware() *ParseAccessKeyMiddleware

func (*ParseAccessKeyMiddleware) Handle

type Resp

type Resp struct {
	Code      int32  `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Msg       string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
	RequestID string `protobuf:"bytes,3,opt,name=requestID,proto3" json:"requestID,omitempty"`
	Path      string `protobuf:"bytes,4,opt,name=path,proto3" json:"path,omitempty"`
	// contains filtered or unexported fields
}

func (*Resp) Descriptor deprecated

func (*Resp) Descriptor() ([]byte, []int)

Deprecated: Use Resp.ProtoReflect.Descriptor instead.

func (*Resp) GetCode

func (x *Resp) GetCode() int32

func (*Resp) GetMsg

func (x *Resp) GetMsg() string

func (*Resp) GetPath

func (x *Resp) GetPath() string

func (*Resp) GetRequestID

func (x *Resp) GetRequestID() string

func (*Resp) ProtoMessage

func (*Resp) ProtoMessage()

func (*Resp) ProtoReflect

func (x *Resp) ProtoReflect() protoreflect.Message

func (*Resp) Reset

func (x *Resp) Reset()

func (*Resp) String

func (x *Resp) String() string

Jump to

Keyboard shortcuts

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