api

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_TIMEOUT = 10 * time.Second

DEFAULT_TIMEOUT the default timeout of team specification.

Functions

func ToObject

func ToObject[T any](obj HTTPResponse) (T, error)

ToObject transform HTTPResponse.GetBody to any object using json encoding.

Types

type ClientExternalSurroundingLog added in v0.16.6

type ClientExternalSurroundingLog struct {
	AppName      string                 `json:"app_name"`
	Path         string                 `json:"path"`
	Host         string                 `json:"host"`
	Url          string                 `json:"url"`
	Request      SurroundingLogRequest  `json:"request"`
	Response     SurroundingLogResponse `json:"response"`
	ResponseTime time.Duration          `json:"response_time"`
	MemoryUsage  uint64                 `json:"memory_usage"`
}

type HTTPClient added in v0.16.0

type HTTPClient interface {
	// Call send given request using HTTP, and optionally set custom timeout if
	// provided, otherwise will use DEFAULT_TIMEOUT.
	//
	// This function also help setting any necessary metadata for spotlibs using
	// ctx pkg that also come from this lib.
	Call(req *http.Request, timeouts ...time.Duration) (HTTPResponse, error)
}

func NewHTTPClient added in v0.16.0

func NewHTTPClient() HTTPClient

NewHTTPClient return HTTPClient implementer that also set some metadata header before sending the request.

type HTTPClientExternal added in v0.16.6

type HTTPClientExternal interface {
	// Call send given request using HTTP, and optionally set custom timeout if
	// provided, otherwise will use DEFAULT_TIMEOUT.
	//
	// This function also help setting any necessary metadata for spotlibs using
	// ctx pkg that also come from this lib.
	Call(requestClient context.Context, req *http.Request, timeouts ...time.Duration) (HTTPResponse, error)
}

func NewHTTPClientExternal added in v0.16.6

func NewHTTPClientExternal() HTTPClientExternal

NewHTTPClientExternal return HTTPClient implementer that also set some metadata header before sending the request.

type HTTPResponse added in v0.16.0

type HTTPResponse interface {
	// GetStatusCode get the http status code.
	GetStatusCode() int
	// GetBody get the raw response body in bytes.
	GetBody() []byte
	// GetHeaders get the original response header, after combining the value to
	// one using comma.
	GetHeaders() map[string]string
	// GetHeader get the response header by the given key after combining the value
	// using comma.
	GetHeader(key string) string
}

type MapRoute added in v0.16.6

type MapRoute struct {
	Flag    bool   `json:"flag"`
	MockURL string `json:"mock_url"`
}

type SOAPClient added in v0.19.3

type SOAPClient interface {
	// Call sends a SOAP request to the given URL with the specified action
	// and parameters. Returns the raw content of <{Action}Result> element
	// (typically a JSON string for .NET services).
	//
	// The caller is responsible for unmarshaling the result bytes.
	Call(ctx context.Context, url string, action string, params map[string]string, timeouts ...time.Duration) ([]byte, error)
}

SOAPClient is the interface for making SOAP calls.

func NewSOAPClient added in v0.19.3

func NewSOAPClient(opts ...SOAPOption) SOAPClient

NewSOAPClient creates a new SOAP client with the given options.

type SOAPFault added in v0.19.3

type SOAPFault struct {
	Code   string // e.g. "soap:Server" (1.1) or "env:Sender" (1.2)
	Reason string // human-readable error message
	Detail string // optional detail content
}

SOAPFault represents a parsed SOAP fault from either version.

func (*SOAPFault) Error added in v0.19.3

func (f *SOAPFault) Error() string

Error implements the error interface.

type SOAPOption added in v0.19.3

type SOAPOption func(*soapClient)

SOAPOption is a functional option for configuring SOAPClient.

func WithSOAPVersion added in v0.19.3

func WithSOAPVersion(v SOAPVersion) SOAPOption

WithSOAPVersion sets the SOAP protocol version. Default is SOAP11.

func WithTargetNamespace added in v0.19.3

func WithTargetNamespace(ns string) SOAPOption

WithTargetNamespace sets the target namespace for SOAP actions. Default is "http://tempuri.org/".

func WithWSSecurity added in v0.19.3

func WithWSSecurity(ws WSSecurity) SOAPOption

WithWSSecurity enables WS-Security with the given configuration.

type SOAPSurroundingLog added in v0.19.3

type SOAPSurroundingLog struct {
	AppName      string                 `json:"app_name"`
	Path         string                 `json:"path"`
	Host         string                 `json:"host"`
	URL          string                 `json:"url"`
	SOAPAction   string                 `json:"soap_action"`
	SOAPVersion  string                 `json:"soap_version"`
	Request      SurroundingLogRequest  `json:"request"`
	Response     SurroundingLogResponse `json:"response"`
	ResponseTime time.Duration          `json:"response_time"`
	MemoryUsage  uint64                 `json:"memory_usage"`
}

SOAPSurroundingLog holds the data for surrounding log of SOAP calls.

type SOAPVersion added in v0.19.3

type SOAPVersion int

SOAPVersion represents the SOAP protocol version.

const (
	// SOAP11 uses namespace http://schemas.xmlsoap.org/soap/envelope/
	// Content-Type: text/xml; charset=utf-8
	// Action via SOAPAction header.
	SOAP11 SOAPVersion = iota

	// SOAP12 uses namespace http://www.w3.org/2003/05/soap-envelope
	// Content-Type: application/soap+xml; charset=utf-8; action="..."
	// Action embedded in Content-Type.
	SOAP12
)

type SurroundingLogRequest added in v0.16.6

type SurroundingLogRequest struct {
	Method string `json:"method"`
	Header any    `json:"header"`
	Body   any    `json:"body"`
}

type SurroundingLogResponse added in v0.16.6

type SurroundingLogResponse struct {
	HttpCode int `json:"http_code"`
	Header   any `json:"header"`
	Body     any `json:"body"`
}

type WSPasswordType added in v0.19.3

type WSPasswordType int

WSPasswordType represents the password encoding type for WS-Security.

const (
	// WSPasswordPlainText sends password as plain text.
	WSPasswordPlainText WSPasswordType = iota

	// WSPasswordDigest sends password as Base64(SHA1(Nonce + Created + Password)).
	WSPasswordDigest
)

type WSSecurity added in v0.19.3

type WSSecurity struct {
	Username     string
	Password     string
	PasswordType WSPasswordType
	AddTimestamp bool          // Add wsu:Timestamp to Security header
	AddNonce     bool          // Add Nonce to UsernameToken (always true for Digest)
	TimestampTTL time.Duration // Timestamp validity duration (default: 5 minutes)
}

WSSecurity holds the configuration for WS-Security UsernameToken.

Jump to

Keyboard shortcuts

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