common

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const RequestIDHeader = "Httpmq-Request-ID"

RequestIDHeader is expected HTTP header field carrying the httpmq request ID

Variables

This section is empty.

Functions

func DefineAPIClient

func DefineAPIClient(
	serverURL string, transport *http.Client, userAgent *string, debug bool,
) (*api.APIClient, error)

DefineAPIClient create an API client object targeting a specific httpmq server URL

@param serverUrl string - httpmq server URL
@param transport *http.Client - HTTP client used by the API
@param userAgent *string - user agent to use if not nil
@param debug bool - whether to enable API debug logging
@return client object

func FetchUserProvidedRequestID added in v0.3.0

func FetchUserProvidedRequestID(ctxt context.Context) *string

FetchUserProvidedRequestID reads the user provided request ID from context if present

@param ctxt context.Context - the request context
@return if present, the user provided request ID
        or nil

func GetUnitTestHttpmqDataAPIURL

func GetUnitTestHttpmqDataAPIURL() string

GetUnitTestHttpmqDataAPIURL is a helper function to build the httpmq dataplane API URL for testing

@return the httpmq dataplane API URL

func GetUnitTestHttpmqMgmtAPIURL

func GetUnitTestHttpmqMgmtAPIURL() string

GetUnitTestHttpmqMgmtAPIURL is a helper function to build the httpmq management API URL for testing

@return the httpmq management API URL

Types

type HttpmqAPIError added in v0.3.0

type HttpmqAPIError struct {
	// RequestID is the request ID to match against logs
	RequestID string
	// StatusCode is the response code returned by httpmq
	StatusCode int
	// Message is an optional descriptive message
	Message *string
	// Detail is an optional descriptive message providing additional details on the error
	Detail *string
}

HttpmqAPIError is the custom error returned by httpmq

func GenerateHttpmqError added in v0.3.0

func GenerateHttpmqError(reqID string, statusCode int, err *api.GoutilsErrorDetail) HttpmqAPIError

GenerateHttpmqError generate a HttpmqAPIError object from the error response from httpmq

@param reqID string - the request ID
@param err *api.ApisErrorDetail - the error message
@return a HttpmqAPIError instance

func (HttpmqAPIError) Error added in v0.3.0

func (e HttpmqAPIError) Error() string

Error implements the error interface for HttpmqAPIError

type UseGivenRequestID added in v0.3.0

type UseGivenRequestID struct{}

UseGivenRequestID is the Key type for adding a user provided request ID to a request context

Jump to

Keyboard shortcuts

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