xhttp

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const TypeNode = "xhttp"

Variables

View Source
var (
	ContentTypeApplicationJSON = constants.ContentTypeApplicationJSON
	ContentTypeTextPlain       = constants.ContentTypeTextPlain
	ContentTypeUrlencoded      = constants.ContentTypeUrlencoded
)

Functions

func Deregister

func Deregister(name string)

Deregister 清理配置适配器

func NewBuilder

func NewBuilder() container.StandardBuilder

func Register

func Register(resolver httpResolver)

Register 注册配置文件适配器

Types

type Body

type Body = httputil.Body

type Client

type Client interface {
	//Swap 将当前请求参数作为RPC参数并发送RPC请求
	Swap(ctx context.Context, service string, opts ...RequestOption) (res Body, err error)

	//RequestByCtx RPC请求,可通过context撤销请求
	Request(ctx sctx.Context, service string, input interface{}, opts ...RequestOption) (res Body, err error)
}

type Options

type Options struct {
	Method  string
	Version string
	Header  xtypes.SMap
	Handler RespHandler
}

type RequestOption

type RequestOption func(*Options)

func WithContentType

func WithContentType(contentType string) RequestOption

WithContentType sets the content type for the request.

func WithContentTypeJSON added in v0.7.8

func WithContentTypeJSON() RequestOption

WithContentTypeJSON sets the content type to JSON for the request.

func WithContentTypeUrlencoded added in v0.7.8

func WithContentTypeUrlencoded() RequestOption

WithContentTypeUrlencoded sets the content type to urlencoded for the request.

func WithHeaders

func WithHeaders(header map[string]string) RequestOption

WithHeaders sets the headers for the request.

func WithMethod

func WithMethod(method string) RequestOption

WithMethod sets the method for the request.

func WithRespHandler added in v0.7.8

func WithRespHandler(handler RespHandler) RequestOption

WithRespHandler sets the response handler for the request.

func WithXRequestID

func WithXRequestID(requestID string) RequestOption

WithXRequestID sets the request ID for the request.

type RespHandler added in v0.7.8

type RespHandler = httputil.RespHandler

type StandardHttp

type StandardHttp interface {
	GetHttp(name string) (c Client)
}

func NewXhttp

func NewXhttp(container container.Container) StandardHttp

NewXhttp 服务代理

Jump to

Keyboard shortcuts

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