util

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertValid

func AssertValid(verify types.Verification, data []byte) error

Types

type ErrHashMismatch

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

func (ErrHashMismatch) Error

func (e ErrHashMismatch) Error() string

type HttpClient

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

HttpClient is a simple wrapper around the Go HTTP client that standardizes the process and logging of fetching payloads.

func NewHttpClient

func NewHttpClient(logger *log.Logger) HttpClient

NewHttpClient creates a new client with the given logger.

func (HttpClient) FetchConfig

func (c HttpClient) FetchConfig(url string, acceptedStatuses ...int) []byte

FetchConfig fetches a raw config from the provided URL and returns the response body on success or nil on failure. The caller must also provide a list of acceptable HTTP status codes. If the response's status code is not in the provided list, it is considered a failure. The HTTP response must be OK, otherwise an empty (v.s. nil) config is returned.

func (HttpClient) Get

func (c HttpClient) Get(url string) ([]byte, int, error)

Get performs an HTTP GET on the provided URL and returns the response body, HTTP status code, and error (if any).

func (HttpClient) GetWithHeader

func (c HttpClient) GetWithHeader(url string, header http.Header) ([]byte, int, error)

Get performs an HTTP GET on the provided URL with the provided request header and returns the response body, HTTP status code, and error (if any). By default, User-Agent and Accept are added to the header but these can be overridden.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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