client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: MIT Imports: 13 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(url url.URL, activity schema.Activity) error
	Delete(url url.URL, activity schema.Activity) 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
}

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
}

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

func (*ConnectorClient) Delete

func (client *ConnectorClient) Delete(target url.URL, activity schema.Activity) 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) Post

func (client *ConnectorClient) Post(target url.URL, activity schema.Activity) 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.

Jump to

Keyboard shortcuts

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