http

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 21 Imported by: 15

Documentation

Index

Constants

View Source
const (
	OpenapiPathGetToken  = "/auth/v1/appToken"
	FaaSInfraPathSendLog = "/log/v1/namespaces/:namespace/logs/batchSend"
	InnerAPIGetFunction  = "/cloudfunction/v1/namespaces/:namespace/functions/detail"
)

Variables

This section is empty.

Functions

func AppTokenMiddleware

func AppTokenMiddleware(ctx context.Context, req *http.Request) (err error)

func AppendParamsUnauthFields added in v0.0.19

func AppendParamsUnauthFields(ctx context.Context, funcAPIName string, inputOrOutput string, params interface{}, unauthFieldsMap map[string]interface{}) (context.Context, error)

AppendParamsUnauthFields 处理参数中的权限 提取权限信息

func AppendUnauthFieldRecord added in v0.0.19

func AppendUnauthFieldRecord(ctx context.Context, objectAPIName string, recordOrID interface{}, unauthFields []string)

func AppendUnauthFieldRecordList added in v0.0.19

func AppendUnauthFieldRecordList(ctx context.Context, objectAPIName string, records interface{}, unauthFieldsList [][]string)

func CalcParamsNeedPermission added in v0.0.19

func CalcParamsNeedPermission(ctx context.Context, funcAPIName string, inputOrOutput string, params interface{}) *structs.Permission

CalcParamsNeedPermission 计算参数需要的权限,返回权限信息

func GetAppTokenHttp

func GetAppTokenHttp(ctx context.Context, clientID, clientSecret string) (*structs.AppTokenResp, error)

func GetFaaSInfraPathSendLog

func GetFaaSInfraPathSendLog() string

func GetFunctionMetaConfWithCache added in v0.0.19

func GetFunctionMetaConfWithCache(ctx context.Context, apiName string) *structs.FunctionMeta

func GetFunctionMetaFromRemote added in v0.0.19

func GetFunctionMetaFromRemote(ctx context.Context, apiName string) (functionMeta *structs.FunctionMeta, err error)

func GetFunctionMetaHttp added in v0.0.19

func GetFunctionMetaHttp(ctx context.Context, apiName string) (funcMeta *structs.FunctionMeta, err error)

func GetInnerAPIPathGetFunction added in v0.0.19

func GetInnerAPIPathGetFunction() string

func GetTimeoutCtx

func GetTimeoutCtx(ctx context.Context) (context.Context, context.CancelFunc)

func SendLog

func SendLog(ctx context.Context, data interface{}) error

func ServiceIDMiddleware

func ServiceIDMiddleware(ctx context.Context, req *http.Request) error

func SetCredentialToCtx

func SetCredentialToCtx(ctx context.Context, credential *AppCredential) context.Context

func TenantAndUserMiddleware

func TenantAndUserMiddleware(ctx context.Context, req *http.Request) error

func TimeoutDialer

func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(ctx context.Context, net, addr string) (c net.Conn, err error)

TimeoutDialer 设置连接&读写超时,非 0 才设置

Types

type AppCredential

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

func NewAppCredential

func NewAppCredential(id, secret string) *AppCredential

func (*AppCredential) GetTenantInfo

func (c *AppCredential) GetTenantInfo(ctx context.Context) (*structs.Tenant, error)

type ClientType

type ClientType int
const (
	OpenAPIClient ClientType = iota + 1
	FaaSInfraClient
)

type HttpClient

type HttpClient struct {
	Type ClientType
	http.Client
	MeshClient *http.Client
	FromSDK    version.ISDKInfo
}

func GetFaaSInfraClient

func GetFaaSInfraClient(ctx context.Context) *HttpClient

func GetOpenapiClient

func GetOpenapiClient() *HttpClient

func (*HttpClient) DeleteJson

func (c *HttpClient) DeleteJson(ctx context.Context, path string, headers map[string][]string, data interface{}, midList ...ReqMiddleWare) ([]byte, map[string]interface{}, error)

func (*HttpClient) Get

func (c *HttpClient) Get(ctx context.Context, path string, headers map[string][]string, midList ...ReqMiddleWare) ([]byte, map[string]interface{}, error)

func (*HttpClient) PatchJson

func (c *HttpClient) PatchJson(ctx context.Context, path string, headers map[string][]string, data interface{}, midList ...ReqMiddleWare) ([]byte, map[string]interface{}, error)

func (*HttpClient) PostBson

func (c *HttpClient) PostBson(ctx context.Context, path string, headers map[string][]string, data interface{}, midList ...ReqMiddleWare) ([]byte, map[string]interface{}, error)

func (*HttpClient) PostFormData

func (c *HttpClient) PostFormData(ctx context.Context, path string, headers map[string][]string, body *bytes.Buffer, midList ...ReqMiddleWare) ([]byte, map[string]interface{}, error)

func (*HttpClient) PostJson

func (c *HttpClient) PostJson(ctx context.Context, path string, headers map[string][]string, data interface{}, midList ...ReqMiddleWare) ([]byte, map[string]interface{}, error)

type ICredential

type ICredential interface {
	// contains filtered or unexported methods
}

type ReqMiddleWare

type ReqMiddleWare func(ctx context.Context, req *http.Request) error

Jump to

Keyboard shortcuts

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