decorator

package
v0.0.0-...-89e5b94 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 4

Documentation

Index

Constants

View Source
const REQUEST = "REQUEST"
View Source
const RESPONSE = "RESPONSE"

Variables

This section is empty.

Functions

func DefaultProtoDecoratorMaker

func DefaultProtoDecoratorMaker(validateFailedCode int32, unexpectedECode int32) func(framework.ConfBeanRegistry, api.ProtoHandler) gin.HandlerFunc

DefaultProtoDecoratorMaker returns default ProtoDecorator.

func InterConnProtoDecoratorMaker

func InterConnProtoDecoratorMaker(validateFailedCode int32, unexpectedECode int32) func(framework.ConfBeanRegistry, api.ProtoHandler) gin.HandlerFunc

InterConnProtoDecoratorMaker returns inter connection ProtoDecorator.

func ProtoDecorator

func ProtoDecorator(e framework.ConfBeanRegistry, handler api.ProtoHandler, options *ProtoDecoratorOptions) gin.HandlerFunc

ProtoDecorator is the decorator of protocol request processing logic. During request processing, ProtoDecorator uses ShouldBindBodyWith of ginContext to read requests with contentType of "text/plain", "application/json" and "", so that other middleware can use ShouldBindBodyWith to read the request body again.

Types

type BizFlow

type BizFlow struct {
	ReqType    *reflect.Type
	RespType   *reflect.Type
	BizContext *api.BizContext
	// contains filtered or unexported fields
}

type PostProcessHandler

type PostProcessHandler func(response api.ProtoResponse, bizContext *api.BizContext)

PostProcessHandler is post processor after frame processing.

type PreRenderHandler

type PreRenderHandler func(bizContext *api.BizContext, render bizrender.Render)

PreRenderHandler is pre processor before rendering results.

type ProtoDecoratorOptions

type ProtoDecoratorOptions struct {
	// Required
	ValidateFailedHandler
	// Required
	UnexpectedErrorHandler
	// Optional
	PostProcessHandler
	// Optional
	PreRenderHandler
	// Optional, have no use if `MarshalOptions` is set
	RenderJSONUseProtoNames bool
	// Optional
	*protojson.MarshalOptions
}

type UnexpectedErrorHandler

type UnexpectedErrorHandler func(flow *BizFlow, errs *errorcode.Errs) api.ProtoResponse

UnexpectedErrorHandler is processor when the framework handles exceptions.

type ValidateFailedHandler

type ValidateFailedHandler func(flow *BizFlow, errs *errorcode.Errs) api.ProtoResponse

ValidateFailedHandler is processor when verification fails.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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