client

package
v0.0.0-...-81dacae Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCantFind          = "CANT_FIND_SERVICE"
	ErrorRequestCreation   = "CANT_CREATE_REQUEST"
	ErrorRequestError      = "ERROR_MAKING_REQUEST"
	ErrorDecodingError     = "ERROR_DECODING_ERROR"
	ErrorDecodingResponse  = "ERROR_DECODING_RESPONSE"
	ErrorMarshallingObject = "ERROR_MARSHALLING_OBJECT"
	ErrorURL               = "ERROR_URL"
)

Error codes

Variables

This section is empty.

Functions

func ObjectToJSONReader

func ObjectToJSONReader(v interface{}) (io.Reader, glitch.DataError)

ObjectToJSONReader will v to a io.Reader of the JSON representation of v

func PrefixRoute

func PrefixRoute(serviceName string, pathPrefix string, appendServiceNameToRoute bool, route string) string

PrefixRoute is a simple helper function to build the route for service to service communicationfunc PrefixRoute(pathPrefix string, appendServiceNameToRoute bool, route string) string {

Types

type BaseClient

type BaseClient interface {
	// Do does the request and parses the body into the response provider if in the 2xx range, otherwise parses it into a glitch.DataError
	Do(ctx context.Context, method string, slug string, query url.Values, headers http.Header, body io.Reader, response interface{}) glitch.DataError

	// MakeRequest does the request and returns the status, body, and any error
	// This should be used only if the api doesn't return glitch.DataErrors
	MakeRequest(ctx context.Context, method string, slug string, query url.Values, headers http.Header, body io.Reader) (int, []byte, glitch.DataError)
}

BaseClient can do requests

func NewBaseClient

func NewBaseClient(finder ServiceFinder, serviceName string, useTLS bool, timeout time.Duration, tlsConfig *tls.Config) BaseClient

NewBaseClient creates a new BaseClient

type ServiceFinder

type ServiceFinder func(serviceName string) (string, error)

ServiceFinder can find a service's base URL

Directories

Path Synopsis
Package clientmock is a generated GoMock package.
Package clientmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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