internal

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHTTPRequest

func BuildHTTPRequest(ctx context.Context, b BuildHTTPRequestOptions) (*http.Request, error)

BuildHTTPRequest builds an *http.Request. All errors are *errors.RequestError.

func IntInSlice

func IntInSlice(i int, want []int) bool

IntInSlice returns true if i is in want

func RelLink(resp *http.Response, lnk string) string

RelLink returns the content of lnk from the response's Link header or "" if it does not exist

func ResponseErrorCheck

func ResponseErrorCheck(resp *http.Response, validStatuses []int) error

ResponseErrorCheck checks for error responses

func SetBoolResult

func SetBoolResult(r *http.Response, ptr *bool) error

SetBoolResult sets the value of ptr to true if r has a 204 status code to true or false if the status code is 404

returns an error if the response is any other value

func String

func String(s string) *string

String returns a pointer to s

func UnmarshalResponseBody

func UnmarshalResponseBody(r *http.Response, target interface{}) error

UnmarshalResponseBody unmarshalls a response body onto target. Non-nil errors will have the type *errors.ResponseError.

Types

type BuildHTTPRequestOptions

type BuildHTTPRequestOptions struct {
	ExplicitURL        string
	Method             string
	RequiredPreviews   []string
	AllPreviews        []string
	HeaderVals         map[string]*string
	Previews           map[string]bool
	Body               interface{}
	URLQuery           url.Values
	URLPath            string
	Options            []requests.Option
	RequireExplicitURL bool
}

BuildHTTPRequestOptions builds http requests

type EndpointAttribute

type EndpointAttribute int

EndpointAttribute is an attribute for an endpoint

type ResponseError

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

ResponseError implements errors.ResponseError

func NewResponseError

func NewResponseError(msg string, resp *http.Response) *ResponseError

NewResponseError returns a new *ResponseError

func (*ResponseError) Data

Data implements errors.ResponseError

func (*ResponseError) Error

func (r *ResponseError) Error() string

func (*ResponseError) HttpResponse

func (r *ResponseError) HttpResponse() *http.Response

HttpResponse implements errors.ResponseError

func (*ResponseError) IsClientError

func (r *ResponseError) IsClientError() bool

IsClientError implements errors.ResponseError

func (*ResponseError) IsServerError

func (r *ResponseError) IsServerError() bool

IsServerError implements errors.ResponseError

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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