client

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMapValue

func GetMapValue(sourceMap map[string]interface{}, keys []string) (interface{}, error)

GetMapValue return the value from map base on the path

func ParseMapSource

func ParseMapSource(source string) (from string, params []string, err error)

ParseMapSource parses the source parameter config in the mappingParams the source parameter in config could be queryStrings.*, headers.*, requestBody.*

Types

type Client

type Client interface {
	Init() error
	Close() error

	// Call invoke the downstream service.
	Call(req *Request) (res interface{}, err error)

	// MapParams mapping param, uri, query, body ...
	MapParams(req *Request) (reqData interface{}, err error)
}

Client represents the interface of http/dubbo clients

type DubboMetadata

type DubboMetadata struct {
	ApplicationName      string   `yaml:"application_name" json:"application_name" mapstructure:"application_name"`
	Group                string   `yaml:"group" json:"group" mapstructure:"group"`
	Version              string   `yaml:"version" json:"version" mapstructure:"version"`
	Interface            string   `yaml:"interface" json:"interface" mapstructure:"interface"`
	Method               string   `yaml:"method" json:"method" mapstructure:"method"`
	Types                []string `yaml:"types" json:"types" mapstructure:"types"`
	Retries              string   `yaml:"retries"  json:"retries,omitempty" property:"retries"`
	ClusterName          string   `yaml:"cluster_name"  json:"cluster_name,omitempty" property:"cluster_name"`
	ProtocolTypeStr      string   `yaml:"protocol_type"  json:"protocol_type,omitempty" property:"protocol_type"`
	SerializationTypeStr string   `yaml:"serialization_type"  json:"serialization_type,omitempty" property:"serialization_type"`
}

DubboMetadata dubbo metadata, api config

type MapOption

type MapOption map[string]RequestOption

MapOption option map, key : name, value : option

type ParamMapper

type ParamMapper interface {
	// Map implements how the request parameters map to the target parameters described by config.MappingParam
	Map(config.MappingParam, *Request, interface{}, RequestOption) error
}

ParamMapper defines the interface about how to map the params in the inbound request.

type Request

type Request struct {
	Context        context.Context
	IngressRequest *http.Request
	API            router.API
}

Request request for endpoint

func NewReq

func NewReq(ctx context.Context, request *http.Request, api router.API) *Request

NewReq create a request

func (*Request) GetURL

func (r *Request) GetURL() string

GetURL new url

type RequestOption

type RequestOption interface {
	Action(target, val interface{}) error
}

RequestOption option interface.

type Response

type Response struct {
	Data interface{}
}

Response response from endpoint

func NewResponse

func NewResponse(data interface{}) *Response

NewResponse create response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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