gateway

package
v0.11.28 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddJsonBodyTenantIDAndUserID added in v0.4.0

func AddJsonBodyTenantIDAndUserID(requestBuilder *RequestBuilder, tenantIDField string, userIDField string) error

func AddQueryParamsTenantIDAndUserID added in v0.4.0

func AddQueryParamsTenantIDAndUserID(requestBuilder *RequestBuilder, tenantIDField string, userIDField string) error

func DestroyGateway

func DestroyGateway(gw *Gateway)

DestroyGateway 销毁网关 参数: - gw: 网关 返回值: 无

Types

type BeforeRequestCallback added in v0.10.5

type BeforeRequestCallback func(requestBuilder *RequestBuilder) error

BeforeRequestCallback 请求发送前的回调

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder 网关API构建器

func (*Builder) AddRoute added in v0.10.5

func (builder *Builder) AddRoute(httpMethod string, relativePath string, handler Handler, middlewares ...Handler)

AddRoute 通用添加API函数 参数: - httpMethod: HTTP方法 - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) AddRouteWithTenantIDAndUserID added in v0.10.5

func (builder *Builder) AddRouteWithTenantIDAndUserID(httpMethod string, relativePath string, tenantIDField string, userIDField string, handler Handler, middlewares ...Handler)

AddRouteWithTenantIDAndUserID 通用添加API函数,会在请求参数(POST和PUT是JsonBody,GET和DELETE是查询参数)添加租户ID和用户ID字段,字段名由调用者指定 参数: - httpMethod: HTTP方法 - relativePath: 该网关API的相对URL - tenantIDField: 租户ID字段名 - userIDField: 用户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) DeleteRoute added in v0.10.5

func (builder *Builder) DeleteRoute(relativePath string, handler Handler, middlewares ...Handler)

DeleteRoute 创建DELETE网关API 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) DeleteRouteWithDeleteUserID added in v0.11.4

func (builder *Builder) DeleteRouteWithDeleteUserID(relativePath string, handler Handler, middlewares ...Handler)

DeleteRouteWithDeleteUserID 创建DELETE网关API,会在查询参数添加用户ID字段,字段名分别为deleteUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) DeleteRouteWithTenantID added in v0.10.5

func (builder *Builder) DeleteRouteWithTenantID(relativePath string, handler Handler, middlewares ...Handler)

DeleteRouteWithTenantID 创建DELETE网关API,会在查询参数添加租户ID字段,字段名分别为tenantId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) DeleteRouteWithTenantIDAndDeleteUserID added in v0.11.4

func (builder *Builder) DeleteRouteWithTenantIDAndDeleteUserID(relativePath string, handler Handler, middlewares ...Handler)

DeleteRouteWithTenantIDAndDeleteUserID 创建DELETE网关API,会在查询参数添加租户ID和用户ID字段,字段名分别为tenantId和deleteUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) DeleteRouteWithTenantIDAndUserID added in v0.10.5

func (builder *Builder) DeleteRouteWithTenantIDAndUserID(relativePath string, handler Handler, middlewares ...Handler)

DeleteRouteWithTenantIDAndUserID 创建DELETE网关API,会在查询参数添加租户ID和用户ID字段,字段名分别为tenantId和userId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) DeleteRouteWithTenantIDAndUserIDCommon added in v0.10.5

func (builder *Builder) DeleteRouteWithTenantIDAndUserIDCommon(relativePath string, tenantIDField string, userIDField string, handler Handler, middlewares ...Handler)

DeleteRouteWithTenantIDAndUserIDCommon 创建DELETE网关API,会在查询参数添加租户ID和用户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - tenantIDField: 租户ID字段名 - userIDField: 用户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) DeleteRouteWithTenantIDCommon added in v0.10.5

func (builder *Builder) DeleteRouteWithTenantIDCommon(relativePath string, tenantIDField string, handler Handler, middlewares ...Handler)

DeleteRouteWithTenantIDCommon 创建DELETE网关API,会在查询参数添加租户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - tenantIDField: 租户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) DeleteRouteWithUserID added in v0.10.5

func (builder *Builder) DeleteRouteWithUserID(relativePath string, handler Handler, middlewares ...Handler)

DeleteRouteWithUserID 创建DELETE网关API,会在查询参数添加用户ID字段,字段名分别为userId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) DeleteRouteWithUserIDCommon added in v0.10.5

func (builder *Builder) DeleteRouteWithUserIDCommon(relativePath string, userIDField string, handler Handler, middlewares ...Handler)

DeleteRouteWithUserIDCommon 创建DELETE网关API,会在查询参数添加用户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - userIDField: 用户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRoute added in v0.10.5

func (builder *Builder) GetRoute(relativePath string, handler Handler, middlewares ...Handler)

GetRoute 创建GET网关API 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithCreateUserID added in v0.11.11

func (builder *Builder) GetRouteWithCreateUserID(relativePath string, handler Handler, middlewares ...Handler)

GetRouteWithCreateUserID 创建GET网关API,会在查询参数添加用户ID字段,字段名分别为createUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithDeleteUserID added in v0.11.11

func (builder *Builder) GetRouteWithDeleteUserID(relativePath string, handler Handler, middlewares ...Handler)

GetRouteWithDeleteUserID 创建GET网关API,会在查询参数添加用户ID字段,字段名分别为deleteUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithTenantID added in v0.10.5

func (builder *Builder) GetRouteWithTenantID(relativePath string, handler Handler, middlewares ...Handler)

GetRouteWithTenantID 创建GET网关API,会在查询参数添加租户ID字段,字段名分别为tenantId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithTenantIDAndCreateUserID added in v0.11.11

func (builder *Builder) GetRouteWithTenantIDAndCreateUserID(relativePath string, handler Handler, middlewares ...Handler)

GetRouteWithTenantIDAndCreateUserID 创建GET网关API,会在查询参数添加租户ID和用户ID字段,字段名分别为tenantId和createUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithTenantIDAndDeleteUserID added in v0.11.11

func (builder *Builder) GetRouteWithTenantIDAndDeleteUserID(relativePath string, handler Handler, middlewares ...Handler)

GetRouteWithTenantIDAndDeleteUserID 创建GET网关API,会在查询参数添加租户ID和用户ID字段,字段名分别为tenantId和deleteUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithTenantIDAndUpdateUserID added in v0.11.11

func (builder *Builder) GetRouteWithTenantIDAndUpdateUserID(relativePath string, handler Handler, middlewares ...Handler)

GetRouteWithTenantIDAndUpdateUserID 创建GET网关API,会在查询参数添加租户ID和用户ID字段,字段名分别为tenantId和updateUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithTenantIDAndUserID added in v0.10.5

func (builder *Builder) GetRouteWithTenantIDAndUserID(relativePath string, handler Handler, middlewares ...Handler)

GetRouteWithTenantIDAndUserID 创建GET网关API,会在查询参数添加租户ID和用户ID字段,字段名分别为tenantId和userId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithTenantIDAndUserIDCommon added in v0.10.5

func (builder *Builder) GetRouteWithTenantIDAndUserIDCommon(relativePath string, tenantIDField string, userIDField string, handler Handler, middlewares ...Handler)

GetRouteWithTenantIDAndUserIDCommon 创建GET网关API,会在查询参数添加租户ID和用户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - tenantIDField: 租户ID字段名 - userIDField: 用户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithTenantIDCommon added in v0.10.5

func (builder *Builder) GetRouteWithTenantIDCommon(relativePath string, tenantIDField string, handler Handler, middlewares ...Handler)

GetRouteWithTenantIDCommon 创建GET网关API,会在查询参数添加租户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - tenantIDField: 租户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithUpdateUserID added in v0.11.11

func (builder *Builder) GetRouteWithUpdateUserID(relativePath string, handler Handler, middlewares ...Handler)

GetRouteWithUpdateUserID 创建GET网关API,会在查询参数添加用户ID字段,字段名分别为updateUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithUserID added in v0.10.5

func (builder *Builder) GetRouteWithUserID(relativePath string, handler Handler, middlewares ...Handler)

GetRouteWithUserID 创建GET网关API,会在查询参数添加用户ID字段,字段名分别为userId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) GetRouteWithUserIDCommon added in v0.10.5

func (builder *Builder) GetRouteWithUserIDCommon(relativePath string, userIDField string, handler Handler, middlewares ...Handler)

GetRouteWithUserIDCommon 创建GET网关API,会在查询参数添加用户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - userIDField: 用户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PostRoute added in v0.10.5

func (builder *Builder) PostRoute(relativePath string, handler Handler, middlewares ...Handler)

PostRoute 创建POST网关API 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PostRouteWithCreateUserID added in v0.11.4

func (builder *Builder) PostRouteWithCreateUserID(relativePath string, handler Handler, middlewares ...Handler)

PostRouteWithCreateUserID 创建POST网关API,请求Body是JsonBody,且会添加用户ID字段,字段名分别为createUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PostRouteWithTenantID added in v0.10.5

func (builder *Builder) PostRouteWithTenantID(relativePath string, handler Handler, middlewares ...Handler)

PostRouteWithTenantID 创建POST网关API,请求Body是JsonBody,且会添加租户ID字段,字段名分别为tenantId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PostRouteWithTenantIDAndCreateUserID added in v0.11.4

func (builder *Builder) PostRouteWithTenantIDAndCreateUserID(relativePath string, handler Handler, middlewares ...Handler)

PostRouteWithTenantIDAndCreateUserID 创建POST网关API,请求Body是JsonBody,且会添加租户ID和用户ID字段,字段名分别为tenantId和createUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PostRouteWithTenantIDAndUserID added in v0.10.5

func (builder *Builder) PostRouteWithTenantIDAndUserID(relativePath string, handler Handler, middlewares ...Handler)

PostRouteWithTenantIDAndUserID 创建POST网关API,请求Body是JsonBody,且会添加租户ID和用户ID字段,字段名分别为tenantId和userId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PostRouteWithTenantIDAndUserIDCommon added in v0.10.5

func (builder *Builder) PostRouteWithTenantIDAndUserIDCommon(relativePath string, tenantIDField string, userIDField string, handler Handler, middlewares ...Handler)

PostRouteWithTenantIDAndUserIDCommon 创建POST网关API,请求Body是JsonBody,且会添加租户ID和用户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - tenantIDField: 租户ID字段名 - userIDField: 用户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PostRouteWithTenantIDCommon added in v0.10.5

func (builder *Builder) PostRouteWithTenantIDCommon(relativePath string, tenantIDField string, handler Handler, middlewares ...Handler)

PostRouteWithTenantIDCommon 创建POST网关API,请求Body是JsonBody,且会添加租户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - tenantIDField: 租户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PostRouteWithUserID added in v0.10.5

func (builder *Builder) PostRouteWithUserID(relativePath string, handler Handler, middlewares ...Handler)

PostRouteWithUserID 创建POST网关API,请求Body是JsonBody,且会添加用户ID字段,字段名分别为userId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PostRouteWithUserIDCommon added in v0.10.5

func (builder *Builder) PostRouteWithUserIDCommon(relativePath string, userIDField string, handler Handler, middlewares ...Handler)

PostRouteWithUserIDCommon 创建POST网关API,请求Body是JsonBody,且会添加用户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - userIDField: 用户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PutRoute added in v0.10.5

func (builder *Builder) PutRoute(relativePath string, handler Handler, middlewares ...Handler)

PutRoute 创建PUT网关API 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PutRouteWithTenantID added in v0.10.5

func (builder *Builder) PutRouteWithTenantID(relativePath string, handler Handler, middlewares ...Handler)

PutRouteWithTenantID 创建PUT网关API,请求Body是JsonBody,且会添加租户ID字段,字段名分别为tenantId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PutRouteWithTenantIDAndUpdateUserID added in v0.11.4

func (builder *Builder) PutRouteWithTenantIDAndUpdateUserID(relativePath string, handler Handler, middlewares ...Handler)

PutRouteWithTenantIDAndUpdateUserID 创建PUT网关API,请求Body是JsonBody,且会添加租户ID和用户ID字段,字段名分别为tenantId和updateUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PutRouteWithTenantIDAndUserID added in v0.10.5

func (builder *Builder) PutRouteWithTenantIDAndUserID(relativePath string, handler Handler, middlewares ...Handler)

PutRouteWithTenantIDAndUserID 创建PUT网关API,请求Body是JsonBody,且会添加租户ID和用户ID字段,字段名分别为tenantId和userId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PutRouteWithTenantIDAndUserIDCommon added in v0.10.5

func (builder *Builder) PutRouteWithTenantIDAndUserIDCommon(relativePath string, tenantIDField string, userIDField string, handler Handler, middlewares ...Handler)

PutRouteWithTenantIDAndUserIDCommon 创建PUT网关API,请求Body是JsonBody,且会添加租户ID和用户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - tenantIDField: 租户ID字段名 - userIDField: 用户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PutRouteWithTenantIDCommon added in v0.10.5

func (builder *Builder) PutRouteWithTenantIDCommon(relativePath string, tenantIDField string, handler Handler, middlewares ...Handler)

PutRouteWithTenantIDCommon 创建PUT网关API,请求Body是JsonBody,且会添加租户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - tenantIDField: 租户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PutRouteWithUpdateUserID added in v0.11.4

func (builder *Builder) PutRouteWithUpdateUserID(relativePath string, handler Handler, middlewares ...Handler)

PutRouteWithUpdateUserID 创建PUT网关API,请求Body是JsonBody,且会添加用户ID字段,字段名分别为updateUserId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PutRouteWithUserID added in v0.10.5

func (builder *Builder) PutRouteWithUserID(relativePath string, handler Handler, middlewares ...Handler)

PutRouteWithUserID 创建PUT网关API,请求Body是JsonBody,且会添加用户ID字段,字段名分别为userId 参数: - relativePath: 该网关API的相对URL - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

func (*Builder) PutRouteWithUserIDCommon added in v0.10.5

func (builder *Builder) PutRouteWithUserIDCommon(relativePath string, userIDField string, handler Handler, middlewares ...Handler)

PutRouteWithUserIDCommon 创建PUT网关API,请求Body是JsonBody,且会添加用户ID字段,字段名由调用者指定 参数: - relativePath: 该网关API的相对URL - userIDField: 用户ID字段名 - handler: 该网关API处理函数 - middlewares: 该网关API的中间件 返回值: 无

type DeleteRequest

type DeleteRequest struct {
	// Url 要发送请求的完整URL
	Url string

	// 查询参数,如果为nil,则默认读取RequestBuilder中上下文中的缓存查询参数
	QueryParams map[string]string

	// 路径参数,如果为nil,则默认读取RequestBuilder中上下文中的缓存路径参数
	PathParams map[string]string
	// contains filtered or unexported fields
}

DeleteRequest DELETE请求

func (*DeleteRequest) Request

func (req *DeleteRequest) Request(c *api.Context, request *http_client.Request) (Request, error)

func (*DeleteRequest) Response

func (req *DeleteRequest) Response() *http_client.Response

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

Gateway 网关结构

func NewGateway

func NewGateway(api *api.Api, opts ...Option) *Gateway

NewGateway 创建网关 参数: - api: 网关使用的白泽API - opts: 选项 返回值: - 网关

func (*Gateway) NewBuilder

func (gw *Gateway) NewBuilder(routerType string, version string, middlewares ...Handler) *Builder

NewBuilder 创建网关API的Builder 参数: - routerType: 路由类型,有两种

  • api.RouterRoot: 根路由
  • api.RouterPrefix: 带url前缀的路由

- version: 版本,用于获取基于上面两中路由够造的带有版本号的路由,传空字符串则选定上面两种路由本身 - middlewares: 该Builder范围的中间件 返回值: - 网关API的Builder

type GetRequest

type GetRequest struct {
	// Url 要发送请求的完整URL
	Url string

	// 查询参数,如果为nil,则默认读取RequestBuilder中上下文中的缓存查询参数
	QueryParams map[string]string

	// 路径参数,如果为nil,则默认读取RequestBuilder中上下文中的缓存路径参数
	PathParams map[string]string
	// contains filtered or unexported fields
}

GetRequest GET请求

func (*GetRequest) Request

func (req *GetRequest) Request(c *api.Context, request *http_client.Request) (Request, error)

func (*GetRequest) Response

func (req *GetRequest) Response() *http_client.Response

type Handler added in v0.10.5

type Handler func(requestBuilder *RequestBuilder)

Handler 网关API处理函数

type Option

type Option func(options *Options)

func WithHttpClientTimeoutSec

func WithHttpClientTimeoutSec(httpClientTimeoutSec int64) Option

WithHttpClientTimeoutSec 设置http客户端的超时时间

type Options

type Options struct {
	// contains filtered or unexported fields
}

type PostRequest

type PostRequest struct {
	// Url 要发送请求的完整URL
	Url string

	// Body请求体,如果为nil,则默认读取RequestBuilder中上下文中的缓存Body
	Body any
	// contains filtered or unexported fields
}

PostRequest POST请求

func (*PostRequest) Request

func (req *PostRequest) Request(c *api.Context, request *http_client.Request) (Request, error)

func (*PostRequest) Response

func (req *PostRequest) Response() *http_client.Response

type PutRequest

type PutRequest struct {
	// Url 要发送请求的完整URL
	Url string

	// Body请求体,如果为nil,则默认读取RequestBuilder中上下文中的缓存Body
	Body any
	// contains filtered or unexported fields
}

PutRequest PUT请求

func (*PutRequest) Request

func (req *PutRequest) Request(c *api.Context, request *http_client.Request) (Request, error)

func (*PutRequest) Response

func (req *PutRequest) Response() *http_client.Response

type Request added in v0.10.5

type Request interface {
	// Request 发送请求
	// 参数:
	// - c: 上下文
	// - request: HTTP客户端请求,用来发送HTTP请求
	// 返回值:
	// - 带有响应的请求接口
	// - 错误
	Request(c *api.Context, request *http_client.Request) (Request, error)

	// Response 获取响应
	// 参数: 无
	// 返回值:
	// - HTTP客户端响应
	Response() *http_client.Response
}

Request 请求接口

type RequestBuilder added in v0.10.5

type RequestBuilder struct {
	// contains filtered or unexported fields
}

RequestBuilder 请求构建器

func (*RequestBuilder) Context added in v0.10.5

func (builder *RequestBuilder) Context() *api.Context

Context 获取上下文 参数: 无 返回值: - 上下文

func (*RequestBuilder) Delete added in v0.10.5

func (builder *RequestBuilder) Delete(request *DeleteRequest, opts ...RequestOption) *RequestBuilder

Delete 定义Delete请求 参数: - request: DeleteRequest - opts: 请求选项 返回值: - RequestBuilder

func (*RequestBuilder) Get added in v0.10.5

func (builder *RequestBuilder) Get(request *GetRequest, opts ...RequestOption) *RequestBuilder

Get 定义Get请求 参数: - request: GetRequest - opts: 请求选项 返回值: - RequestBuilder

func (*RequestBuilder) GetResultMapValue added in v0.10.5

func (builder *RequestBuilder) GetResultMapValue(key string) any

GetResultMapValue 获取结果Map的值 参数: - key: 键 返回值: - 值

func (*RequestBuilder) HistoryRequests added in v0.10.5

func (builder *RequestBuilder) HistoryRequests() []Request

HistoryRequests 获取历史请求(包含响应) 参数: 无 返回值: - 历史请求

func (*RequestBuilder) Post added in v0.10.5

func (builder *RequestBuilder) Post(request *PostRequest, opts ...RequestOption) *RequestBuilder

Post 定义POST请求 参数: - request: PostRequest - opts: 请求选项 返回值: - RequestBuilder

func (*RequestBuilder) Put added in v0.10.5

func (builder *RequestBuilder) Put(request *PutRequest, opts ...RequestOption) *RequestBuilder

Put 定义Put请求 参数: - request: PutRequest - opts: 请求选项 返回值: - RequestBuilder

func (*RequestBuilder) Request added in v0.10.5

func (builder *RequestBuilder) Request()

Request 发送构造的请求链 参数: 无 返回值: 无

func (*RequestBuilder) ResponseError added in v0.10.5

func (builder *RequestBuilder) ResponseError(err error)

ResponseError 利用网关API错误响应回调发送网关API响应 参数: - 错误 返回值: 无

func (*RequestBuilder) ResponseErrorCallback added in v0.10.5

func (builder *RequestBuilder) ResponseErrorCallback(responseErrorCallback ResponseErrorCallback) *RequestBuilder

ResponseErrorCallback 设置网关API错误响应回调 参数: - responseErrorCallback: 网关API错误响应回调,默认回调会按照是否存在错误返回MsgResponse 返回值: - RequestBuilder

func (*RequestBuilder) ResponseSuccess added in v0.11.3

func (builder *RequestBuilder) ResponseSuccess()

ResponseSuccess 利用网关API成功响应回调发送网关API响应 参数: 无 返回值: 无

func (*RequestBuilder) ResponseSuccessCallback added in v0.10.5

func (builder *RequestBuilder) ResponseSuccessCallback(responseSuccessCallback ResponseSuccessCallback) *RequestBuilder

ResponseSuccessCallback 设置网关API成功响应回调 参数: - responseSuccessCallback: 网关API成功响应回调,默认回调会将最后一个请求的响应作为网关API的响应返回 返回值: - RequestBuilder

func (*RequestBuilder) SetResultMapValue added in v0.10.5

func (builder *RequestBuilder) SetResultMapValue(key string, value any)

SetResultMapValue 设置结果Map的值 参数: - key: 键 - 值 返回值: 无

type RequestOption added in v0.10.1

type RequestOption func(options *RequestOptions)

func WithBeforeRequestCallback added in v0.10.5

func WithBeforeRequestCallback(callback BeforeRequestCallback) RequestOption

WithBeforeRequestCallback 设置请求发送前的回调请求选项

func WithRequestResponseCallback added in v0.10.1

func WithRequestResponseCallback(callback RequestResponseCallback) RequestOption

WithRequestResponseCallback 设置请求响应回调请求选项

type RequestOptions added in v0.10.1

type RequestOptions struct {
	// contains filtered or unexported fields
}

type RequestResponseCallback added in v0.4.0

type RequestResponseCallback func(requestBuilder *RequestBuilder, response *http_client.Response) error

RequestResponseCallback 请求响应回调

type ResponseErrorCallback added in v0.4.0

type ResponseErrorCallback func(requestBuilder *RequestBuilder, err error)

ResponseErrorCallback 网关API错误响应回调

type ResponseSuccessCallback added in v0.4.0

type ResponseSuccessCallback func(requestBuilder *RequestBuilder)

ResponseSuccessCallback 网关API成功响应回调

Jump to

Keyboard shortcuts

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