kumoru

package
v0.3.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2016 License: Apache-2.0 Imports: 20 Imported by: 7

Documentation

Index

Constants

View Source
const (
	POST   = "POST"
	GET    = "GET"
	HEAD   = "HEAD"
	PUT    = "PUT"
	DELETE = "DELETE"
	PATCH  = "PATCH"
)

Constant Methods

Variables

View Source
var (
	Version   string
	BuildTime string
)

Functions

func HasTokens

func HasTokens(filename, section string) bool

HasTokens checks a file to make sure there are tokens stored

func LoadRole

func LoadRole(filename string, section string) (string, error)

LoadRole from a file returning the role UUID

func SaveRole

func SaveRole(directory, filename, section string, roleUUID string) error

SaveRole writes the active role to a file

func SaveTokens

func SaveTokens(directory, filename, section string, tokens Ktokens) error

SaveTokens writes tokens to a file

Types

type Client

type Client struct {
	BasicAuth         struct{ UserName, Password string }
	BounceToRawString bool
	Client            *http.Client
	Data              map[string]interface{}
	Debug             bool
	EndPoint          *Endpoints
	Errors            []error
	FormData          url.Values
	Header            map[string]string
	Logger            *log.Logger
	Method            string
	ProxyRequestData  *http.Request
	QueryData         url.Values
	RawString         string
	RoleUUID          string
	Sign              bool
	SliceData         []interface{}
	TargetType        string
	Tokens            *Ktokens
	Transport         *http.Transport
	URL               string
}

Client declartation

func New

func New() *Client

New creates a Client Object.

func (*Client) ClearClient

func (k *Client) ClearClient()

ClearClient clears data for a new request

func (*Client) Delete

func (k *Client) Delete(targetURL string)

Delete method

func (*Client) End

func (k *Client) End(callback ...func(response Response, body string, errs []error)) (Response, string, []error)

End or EndBytes() must be called to execute the call otherwise it won't do a thing.

func (*Client) EndBytes

func (k *Client) EndBytes(callback ...func(response Response, body []byte, errs []error)) (Response, []byte, []error)

EndBytes should be used when you want the body as bytes.

func (*Client) Get

func (k *Client) Get(targetURL string)

Get method

func (*Client) Head

func (k *Client) Head(targetURL string)

Head method

func (*Client) NewRequest

func (k *Client) NewRequest() (*http.Request, error)

NewRequest sets the appropriate header and appropriate request content

func (*Client) Param

func (k *Client) Param(key string, value string)

Param function adds a key value pair to the list of parameters

func (*Client) Patch

func (k *Client) Patch(targetURL string)

Patch method

func (*Client) Post

func (k *Client) Post(targetURL string)

Post method

func (*Client) ProxyRequest

func (k *Client) ProxyRequest(r *http.Request)

ProxyRequest set ProxyRequest Headers

func (*Client) Put

func (k *Client) Put(targetURL string)

Put method

func (*Client) Query

func (k *Client) Query(content interface{})

Query fucntion forms a query-string in the url of GET method or body of POST method. Usage Example:

kumoru.New(). Get("/applications/"). Query(`{ query: 'myapp' }`). Query(`{ limit: '5' }`). End()

kumoru.New(). Get("/applications/"). Query("query=myapp&limit=5"). End()

kumoru.New(). Get("/applications/"). Query("query=myapp&limit=5"). Query(`{ sort: 'asc' }`). End()

func (*Client) Send

func (k *Client) Send(content interface{}) *Client

Send a string or a struct as parameters

func (*Client) SendSlice

func (k *Client) SendSlice(content []interface{}) *Client

SendSlice appends an array into k.SliceData

func (*Client) SendString

func (k *Client) SendString(content string) *Client

SendString sends the information as a raw string

func (*Client) SendStruct

func (k *Client) SendStruct(content interface{}) *Client

SendStruct converts a struct to parameters

func (*Client) SetBasicAuth

func (k *Client) SetBasicAuth(username string, password string)

SetBasicAuth user name and password

func (*Client) SetDebug

func (k *Client) SetDebug(enable bool)

SetDebug enables debugging

func (*Client) SetHeader

func (k *Client) SetHeader(param string, value string)

SetHeader headers kumoru.New(). POST("/application/B8658129-701E-432C-BD80-5D0F464EC932"). SetHeader("Accept", "application/x-www-form-urlencoded")

func (*Client) SetLogger

func (k *Client) SetLogger(logger *log.Logger)

SetLogger enable logger

func (*Client) SignRequest

func (k *Client) SignRequest(enable bool)

SignRequest enables kumoru's authentication

func (*Client) TLSClientConfig

func (k *Client) TLSClientConfig(config *tls.Config)

TLSClientConfig set TLS configuration

type Endpoints

type Endpoints struct {
	Application   string
	Authorization string
	Location      string
}

Endpoints struct for all api services

func LoadEndpoints

func LoadEndpoints(filename string, section string) Endpoints

LoadEndpoints returns and Endpoints struct by reading them from a file or from defaults

type Ktokens

type Ktokens struct {
	Public  string
	Private string
}

Ktokens contains public and private tokens

func LoadTokens

func LoadTokens(filename string, section string) (Ktokens, error)

LoadTokens from a file returning a struct of type Ktokens

type Request

type Request *http.Request

Request declaration

type Response

type Response *http.Response

Response declaration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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