libCallApi

package
v0.10.22 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(username, password string) string

func ConsumeRestJSON added in v0.9.52

func ConsumeRestJSON[Resp ApiResp](c *CallData) (*Resp, response.ErrorState)

func GetJSONResp added in v0.9.52

func GetJSONResp[Resp ApiResp](api RemoteApi, resp *http.Response) (*Resp, response.ErrorState)

func PrepareCall

func PrepareCall(c CallData) (*http.Request, response.ErrorState)

func RemoteCall added in v0.9.52

func RemoteCall[Req any, Resp ApiResp](param *RemoteCallParamData[Req]) (*Resp, response.ErrorState)

func TransmitRequestWithAuth

func TransmitRequestWithAuth(
	path, api, method string,
	requestByte []byte,
	headers map[string]string,
	parseRemoteResp func([]byte, string, int) (int, map[string]string, any, error),
	consumeHandler func([]byte, string, string, string, string, map[string]string) ([]byte, string, int, error),
) (int, map[string]string, any, error)

func TransmitSoap

func TransmitSoap[Resp any](request any, url string, debug bool, timeout time.Duration) (*Resp, error)

Types

type ApiResp added in v0.9.56

type ApiResp interface {
	SetStatus(int)
	SetHeaders(map[string]string)
}

type CallApiInterface

type CallApiInterface interface {
	GetApi(apiName string) RemoteApi
	ConsumeRestBasicAuthApi(requestJson []byte, apiName, path, contentType, method string, headers map[string]string) ([]byte, string, error)
	ConsumeRestApi(requestJson []byte, apiName, path, contentType, method string, headers map[string]string) ([]byte, string, int, error)
}

type CallData

type CallData struct {
	Api       RemoteApi
	Path      string
	Method    string
	Headers   map[string]string
	Req       any
	SslVerify bool
	Timeout   time.Duration
	EnableLog bool
	LogLevel  int
}

func (CallData) SetLogs added in v0.3.3

func (c CallData) SetLogs(req *http.Request) *http.Request

type CallParam added in v0.3.4

type CallParam *CallParamData

type CallParamData added in v0.9.16

type CallParamData struct {
	Parameters  map[string]any
	Headers     map[string]string
	Api         RemoteApi
	Timeout     time.Duration
	Method      string
	Path        string
	Query       string
	QueryStack  *[]string
	ValidateTls bool
	EnableLog   bool
	JsonBody    any
}

type CallResp

type CallResp struct {
	Headers map[string]string
	Status  int
}

func ConsumeRest

func ConsumeRest[Resp any](c CallData) (*Resp, *response.WsRemoteResponse, *CallResp, response.ErrorState)

func GetResp

func GetResp[Resp any, Error any](api RemoteApi, resp *http.Response) (*Resp, *Error, *CallResp, response.ErrorState)

type CallResult added in v0.3.4

type CallResult[RespType any] struct {
	Resp   *RespType
	WsResp *response.WsRemoteResponse
	Status *CallResp
	Error  response.ErrorState
}

func Call added in v0.3.4

func Call[RespType any](param CallParam) CallResult[RespType]

func MultiCall added in v0.3.6

func MultiCall(paramList []CallParam, core CallApiInterface) []CallResult[response.WsRemoteResponse]

type RemoteApi

type RemoteApi struct {
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Domain   string `yaml:"domain"`
	Name     string `yaml:"name"`
}

type RemoteApiModel

type RemoteApiModel struct {
	RemoteApiList map[string]RemoteApi
}

func (RemoteApiModel) ConsumeRestApi

func (m RemoteApiModel) ConsumeRestApi(requestJson []byte, apiName, path, contentType, method string, headers map[string]string) ([]byte, string, int, error)

func (RemoteApiModel) ConsumeRestBasicAuthApi

func (m RemoteApiModel) ConsumeRestBasicAuthApi(requestJson []byte, apiName, path, contentType, method string, headers map[string]string) ([]byte, string, error)

func (RemoteApiModel) GetApi

func (m RemoteApiModel) GetApi(apiName string) RemoteApi

type RemoteCallParamData added in v0.9.52

type RemoteCallParamData[Req any] struct {
	Parameters  map[string]any
	Headers     map[string]string
	Api         RemoteApi
	Timeout     time.Duration
	Method      string
	Path        string
	Query       string
	QueryStack  *[]string
	ValidateTls bool
	EnableLog   bool
	JsonBody    Req
}

type TypeList added in v0.3.6

type TypeList interface {
	GetType(int) any
}

Jump to

Keyboard shortcuts

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