protocol

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 5 Imported by: 1

README

Forward Protocol Support

This package is used to support other backend protocols and perform conversion operations from HTTP to various protocols such as HTTP, tRPC, gRPC, and WebSocket.

Directory Structure
  • cliprotocol.go Protocol conversion interface definition
  • http HTTP to HTTP conversion
  • trpc HTTP to tRPC conversion
  • grpc HTTP to tRPC conversion

You can implement the cliprotocol.go interface to enable custom protocol conversion for your business.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCliProtocolHandler

func RegisterCliProtocolHandler(protocol string, handler CliProtocolHandler)

RegisterCliProtocolHandler registers downstream protocol handler

Types

type CliProtocolHandler

type CliProtocolHandler interface {
	// WithCtx sets the context header
	WithCtx(ctx context.Context) (context.Context, error)
	// GetCliOptions gets specific client options for the request
	GetCliOptions(ctx context.Context) ([]client.Option, error)
	// TransReqBody transforms the request body
	TransReqBody(ctx context.Context) (interface{}, error)
	// TransRspBody transforms the response body
	TransRspBody(ctx context.Context) (interface{}, error)
	// HandleErr handles error information
	HandleErr(ctx context.Context, err error) error
	// HandleRspBody handles the response
	HandleRspBody(ctx context.Context, rspBody interface{}) error
}

CliProtocolHandler handles downstream requests based on the downstream client request protocol type

func GetCliProtocolHandler

func GetCliProtocolHandler(protocol string) (CliProtocolHandler, error)

GetCliProtocolHandler gets the downstream protocol handler based on the protocol

Directories

Path Synopsis
grpc module
Package http converts fasthttp requests to net/http requests It refers to the logic of net/http/httputil/reverseproxy.go
Package http converts fasthttp requests to net/http requests It refers to the logic of net/http/httputil/reverseproxy.go
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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