Documentation
¶
Index ¶
- Constants
- Variables
- func Duration(d time.Duration, dicimal int) time.Duration
- func NewLoggingTransport(transport http.RoundTripper) *http.Client
- func XID() string
- type ClientOption
- type LoggingTransport
- type RestClient
- func (c *RestClient) DELETE(uri string, request, response interface{}) (int, error)
- func (c *RestClient) GET(uri string, response interface{}) (int, error)
- func (c *RestClient) POST(uri string, request, response interface{}) (int, error)
- func (c *RestClient) PUT(uri string, request, response interface{}) (int, error)
- func (c *RestClient) SetClient(cl *http.Client)
Constants ¶
View Source
const ( HTTP_ENDPOINT = "HTTP_ENDPOINT" FORCE_TRACE = "FORCE_TRACE" ApiAgent = "txsvc/rest" // format error messages MsgStatus = "%s. status: %d" )
Variables ¶
View Source
var ( // ErrApiInvocationError indicates an error in an API call ErrApiInvocationError = errors.New("api invocation error") )
Functions ¶
func NewLoggingTransport ¶
func NewLoggingTransport(transport http.RoundTripper) *http.Client
Types ¶
type ClientOption ¶
type ClientOption interface {
Apply(ds *settings.DialSettings)
}
func WithCredentials ¶
func WithCredentials(clientid, secret string) ClientOption
WithCredentials returns a ClientOption that overrides the default credentials used for a service.
func WithEndpoint ¶
func WithEndpoint(url string) ClientOption
WithEndpoint returns a ClientOption that overrides the default endpoint to be used for a service.
func WithToken ¶
func WithToken(clientid, token string) ClientOption
WithCredentials returns a ClientOption that overrides the default token used for a service.
type LoggingTransport ¶
type LoggingTransport struct {
InnerTransport http.RoundTripper
}
RestClient - API client encapsulating the http client
type RestClient ¶
type RestClient struct { HttpClient *http.Client Settings *settings.DialSettings Trace string }
RestClient - API client encapsulating the http client
func NewRestClient ¶
func NewRestClient(ctx context.Context, opts ...ClientOption) (*RestClient, error)
func (*RestClient) DELETE ¶
func (c *RestClient) DELETE(uri string, request, response interface{}) (int, error)
func (*RestClient) GET ¶
func (c *RestClient) GET(uri string, response interface{}) (int, error)
GET is used to request data from the API. No payload, only queries!
func (*RestClient) POST ¶
func (c *RestClient) POST(uri string, request, response interface{}) (int, error)
func (*RestClient) PUT ¶
func (c *RestClient) PUT(uri string, request, response interface{}) (int, error)
func (*RestClient) SetClient ¶
func (c *RestClient) SetClient(cl *http.Client)
Click to show internal directories.
Click to hide internal directories.