internal

package
v0.0.0-...-1638020 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetMeRequest       = "GetMe"
	GetProjectsRequest = "GetProjects"
)

Naming convention:

Method + non-parameter parts of the path

If the request returns a single entity by GUID, use the singular (for example /projects/{project_id} is GetProject).

The const name should always be the const value + Request.

Variables

View Source
var APIRoutes = rata.Routes{
	{Path: "/me", Method: http.MethodGet, Name: GetMeRequest},
	{Path: "/projects", Method: http.MethodGet, Name: GetProjectsRequest},
}

APIRoutes is a list of routes used by the rata library to construct request URLs.

Functions

func DecodeJSON

func DecodeJSON(raw []byte, v interface{}) error

DecodeJSON unmarshals JSON into the given object with the appropriate settings.

Types

type Clock

type Clock interface {
	Now() time.Time
}

type Connection

type Connection interface {
	Make(request *Request, passedResponse *Response) error
}

Connection creates and executes http requests

type ConnectionConfig

type ConnectionConfig struct {
	SkipSSLValidation bool
}

ConnectionConfig is for configuring a TrackerConnection.

type ConnectionWrapper

type ConnectionWrapper interface {
	Connection
	Wrap(innerconnection Connection) Connection
}

ConnectionWrapper can wrap a given connection allowing the wrapper to modify all requests going in and out of the given connection.

type ErrorWrapper

type ErrorWrapper struct {
	// contains filtered or unexported fields
}

ErrorWrapper is the wrapper that converts responses with 4xx and 5xx status codes to an error.

func NewErrorWrapper

func NewErrorWrapper() *ErrorWrapper

func (*ErrorWrapper) Make

func (e *ErrorWrapper) Make(request *Request, passedResponse *Response) error

Make creates a connection in the wrapped connection and handles errors that it returns.

func (*ErrorWrapper) Wrap

func (e *ErrorWrapper) Wrap(inner Connection) Connection

Wrap wraps a connection in this error handling wrapper.

type RealTime

type RealTime struct{}

func (RealTime) Now

func (RealTime) Now() time.Time

type Request

type Request struct {
	*http.Request
	// contains filtered or unexported fields
}

Request represents the request of the cloud controller.

func NewRequest

func NewRequest(request *http.Request, body io.ReadSeeker) *Request

func (*Request) ResetBody

func (r *Request) ResetBody() error

type Response

type Response struct {
	// DecodeJSONResponseInto represents the resource entity type that is
	// expected in the response JSON.
	DecodeJSONResponseInto interface{}

	// RawResponse represents the response body.
	RawResponse []byte

	// Warnings represents warnings parsed from the custom warnings headers of a
	// Tracker response.
	Warnings []string

	// HTTPResponse represents the HTTP response object.
	HTTPResponse *http.Response

	// ResourceLocationURL represents the Location header value
	ResourceLocationURL string
}

Response represents a Tracker response object.

type TokenWrapper

type TokenWrapper struct {
	APIToken string
	// contains filtered or unexported fields
}

TokenWrapper adds the API Token to every request.

func NewTokenWrapper

func NewTokenWrapper(token string) *TokenWrapper

func (*TokenWrapper) Make

func (e *TokenWrapper) Make(request *Request, passedResponse *Response) error

Make adds the API Token header to every request before sending it.

func (*TokenWrapper) Wrap

func (e *TokenWrapper) Wrap(inner Connection) Connection

Wrap wraps a connection with this wrapper.

type TrackerConnection

type TrackerConnection struct {
	HTTPClient *http.Client
	UserAgent  string
}

TrackerConnection represents a connection to the Cloud Controller server.

func NewTrackerConnection

func NewTrackerConnection(config ConnectionConfig) *TrackerConnection

NewTrackerConnection returns a new TrackerConnection with provided configuration.

func (*TrackerConnection) Make

func (connection *TrackerConnection) Make(request *Request, passedResponse *Response) error

Make performs the request and parses the response.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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