client

package
v0.0.0-...-057a142 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSavedRequest

func LoadSavedRequest(rset *RequestSet) (*http.Request, error)

LoadSavedRequest accepts a string from arg in running command as dot.notation. Looks up against the requests.yaml, loads it and searches for the request. The saved request in requests.yaml could be <name>: <url string>. Can also be <name>: {url: <string>, body: <json>, header: {<key>:<value>}} Currently only supports 1 request file and reads whole file - this can be re-visited.

func NewClient

func NewClient() *brangClient

Returns a new *brangClient, which is a wrapper of *http.Client

Types

type Auth

type Auth struct {
	AuthType string `yaml:"authType,omitempty" json:"authType,omitempty"`
	Token    string `yaml:"token,omitempty" json:"token,omitempty"`
	Username string `yaml:"username,omitempty" json:"username,omitempty"`
	Password string `yaml:"password,omitempty" json:"password,omitempty"`
}

Auth holds the authentication data for building HTTP Auth Headers. Allowed AuthTypes are: Password, Bearer, Token, or empty string If AuthType is passed value of 'Basic' it will be handled as 'Password'

func (*Auth) PasswordAuth

func (a *Auth) PasswordAuth() string

Returns value for Authorization Header as "Basic username:pasword"

func (*Auth) TokenAuth

func (a *Auth) TokenAuth() string

Returns value for Authorization Header as "Bearer|Token the-token-123"

type BResponse

type BResponse struct {
	*http.Response
	OutBody bytes.Buffer
	// contains filtered or unexported fields
}

func NewBResponse

func NewBResponse() *BResponse

func (*BResponse) AddError

func (br *BResponse) AddError(e error)

func (*BResponse) CaptureResponse

func (br *BResponse) CaptureResponse(r *http.Response, e error)

func (*BResponse) StringResponseBody

func (br *BResponse) StringResponseBody() string

func (*BResponse) Write

func (br *BResponse) Write(p []byte) (n int, err error)

func (*BResponse) WriteResponse

func (br *BResponse) WriteResponse()

type BResponseCapturer

type BResponseCapturer interface {
	CaptureResponse(*http.Response, error)
}

type BResponseHandler

type BResponseHandler interface {
	BResponseWriter
	BResponseCapturer
}

type BResponseWriter

type BResponseWriter interface {
	WriteResponse()
}

type RequestSet

type RequestSet struct {
	URL,
	Method,
	AuthType,
	Cred,
	Params,
	Body string
	HeaderSlice []string
}

func (*RequestSet) BodyFile

func (rset *RequestSet) BodyFile(f string) error

Takes path to a file with body for a request. Reads it and attaches to request.

func (*RequestSet) BuildHeader

func (rset *RequestSet) BuildHeader() (*http.Header, error)

Makes a *http.Header from data provided to attach to a http.Request

func (*RequestSet) BuildRequest

func (rset *RequestSet) BuildRequest() (*http.Request, error)

Creates new *http.Request and attaches a *http.Header

func (*RequestSet) Send

func (rset *RequestSet) Send()

type SavedRequestSet

type SavedRequestSet struct {
	URL    string
	Body   string
	Header map[string]string
}

Jump to

Keyboard shortcuts

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