middleware

package
v0.0.4 Latest Latest
Warning

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

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

Documentation

Overview

*

@author: taco
@Date: 2023/10/18
@Time: 10:34

*

*

@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 CommonErrResponse

func CommonErrResponse(w http.ResponseWriter, r *http.Request, Code int32, v ...any)

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 CorsMiddleware

type CorsMiddleware struct {
}

CorsMiddleware 跨域请求处理中间件

func NewCorsMiddleware

func NewCorsMiddleware() *CorsMiddleware

NewCorsMiddleware 新建跨域请求处理中间件

func (*CorsMiddleware) Handle

Handle 跨域请求处理

func (*CorsMiddleware) Handler

func (m *CorsMiddleware) Handler() http.Handler

Handler 跨域请求处理器

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 MiddleWareResp

type MiddleWareResp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type ParseAccessKeyMiddleware

type ParseAccessKeyMiddleware struct {
}

func NewParseAccessKeyMiddleware

func NewParseAccessKeyMiddleware() *ParseAccessKeyMiddleware

func (*ParseAccessKeyMiddleware) Handle

type PathHttpInterceptorMiddleware

type PathHttpInterceptorMiddleware struct {
}

func NewPathHttpInterceptorMiddleware

func NewPathHttpInterceptorMiddleware() *PathHttpInterceptorMiddleware

func (*PathHttpInterceptorMiddleware) 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

type RestJwtAuthInterceptorMiddleware

type RestJwtAuthInterceptorMiddleware struct {
	SvcName string
	Redis   *redis.Redis
}

func NewRestJwtAuthInterceptorMiddleware

func NewRestJwtAuthInterceptorMiddleware(name string, rdb *redis.Redis) *RestJwtAuthInterceptorMiddleware

func (*RestJwtAuthInterceptorMiddleware) Handle

type RestRbacInterceptorMiddleware

type RestRbacInterceptorMiddleware struct {
	SvcName string
	Rbac    *casbin.Enforcer
}

func NewRestRbacInterceptorMiddleware

func NewRestRbacInterceptorMiddleware(name string, rdb *redis.Redis, rbac *casbin.Enforcer) *RestRbacInterceptorMiddleware

func (*RestRbacInterceptorMiddleware) Handle

Jump to

Keyboard shortcuts

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