client

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package client provides a HTTP client for calls to the connector service.

The configuration needed for the call are defined by the struct Config

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Post(ctx context.Context, url url.URL, activity schema.Activity) ([]byte, error)
	Delete(ctx context.Context, url url.URL, activity schema.Activity) ([]byte, error)
	Put(ctx context.Context, url url.URL, activity schema.Activity) ([]byte, error)
	Get(ctx context.Context, url url.URL) ([]byte, error)
}

Client provides interface to send requests to the connector service.

func NewClient

func NewClient(config *Config) (Client, error)

NewClient constructs and returns a new ConnectorClient with provided configuration and an empty cache. Returns error if Config passed is nil.

type Config

type Config struct {
	Credentials auth.CredentialProvider
	AuthURL     url.URL
	AuthClient  *http.Client
	ReplyClient *http.Client
}

Config represents the credentials for a user program and the URL for validating the credentials.

func NewClientConfig

func NewClientConfig(credentials auth.CredentialProvider, tokenURL string) (*Config, error)

NewClientConfig creates configuration for ConnectorClient.

type ConnectorClient

type ConnectorClient struct {
	Config
	cache.AuthCache
	// contains filtered or unexported fields
}

ConnectorClient implements Client to send HTTP requests to the connector service.

func (*ConnectorClient) Delete

func (client *ConnectorClient) Delete(ctx context.Context, target url.URL, activity schema.Activity) ([]byte, error)

Delete an activity.

Creates a HTTP DELETE request with the provided activity ID and a Bearer token in the header. Returns any error as received from the call to connector service.

func (*ConnectorClient) Get added in v0.0.5

func (client *ConnectorClient) Get(ctx context.Context, target url.URL) ([]byte, error)

Get an response.

Creates a HTTP GET request with a Bearer token in the header. Returns any error as received from the call to connector service.

func (*ConnectorClient) Post

func (client *ConnectorClient) Post(ctx context.Context, target url.URL, activity schema.Activity) ([]byte, error)

Post an activity to given URL.

Creates a HTTP POST request with the provided activity as the body and a Bearer token in the header. Returns any error as received from the call to connector service.

func (*ConnectorClient) Put

func (client *ConnectorClient) Put(ctx context.Context, target url.URL, activity schema.Activity) ([]byte, error)

Put an activity.

Creates a HTTP PUT request with the provided activity payload and a Bearer token in the header. Returns any error as received from the call to connector service.

Jump to

Keyboard shortcuts

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