httpclient

package
v0.0.0-...-86643de Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: BSD-2-Clause Imports: 16 Imported by: 10

Documentation

Overview

this package contains modified code based on following github repo: https://github.com/jaredwilkening/httpclient

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(url string, header Header, user *Auth) (resp *http.Response, err error)

func Do

func Do(t string, url string, header Header, data io.Reader, user *Auth) (*http.Response, error)

func DoTimeout

func DoTimeout(t string, url string, header Header, data io.Reader, user *Auth, ReadWriteTimeout time.Duration) (*http.Response, error)

func Get

func Get(url string, header Header, user *Auth) (resp *http.Response, err error)

func GetTimeout

func GetTimeout(url string, header Header, user *Auth, ReadWriteTimeout time.Duration) (resp *http.Response, err error)

func Post

func Post(url string, header Header, data io.Reader, user *Auth) (resp *http.Response, err error)

func Put

func Put(url string, header Header, data io.Reader, user *Auth) (resp *http.Response, err error)

Types

type Auth

type Auth struct {
	Type     string
	Username string
	Password string
	Token    string
}

func GetUserByBasicAuth

func GetUserByBasicAuth(username, password string) (user *Auth)

func GetUserByTokenAuth

func GetUserByTokenAuth(token string) (user *Auth)

support multiple token types with datatoken backwards compatable, if no type given default to OAuth

type Form

type Form struct {
	Length      int64
	Reader      io.Reader
	ContentType string
	// contains filtered or unexported fields
}

func NewForm

func NewForm() (f *Form)

func (*Form) AddFile

func (f *Form) AddFile(name, path string)

func (*Form) AddFileReader

func (f *Form) AddFileReader(name string, r io.Reader, size int64)

func (*Form) AddParam

func (f *Form) AddParam(key, val string)

func (*Form) Create

func (f *Form) Create() (err error)

func (*Form) Dump

func (f *Form) Dump() (buf []byte)

func (*Form) Print

func (f *Form) Print() (msg string)
type Header http.Header

type PageItem

type PageItem struct {
	Data interface{}
}

type RestClient

type RestClient struct {
	User   *Auth
	Header Header
	Page   *pagination
}

func (*RestClient) Delete

func (rc *RestClient) Delete(url string) (jsonstream []byte, err error)

func (*RestClient) Get

func (rc *RestClient) Get(url string) (jsonstream []byte, err error)

func (*RestClient) InitPagination

func (rc *RestClient) InitPagination(url string, pageName string, offsetName string)

func (*RestClient) Next

func (rc *RestClient) Next() (item *PageItem, err error)

if error is io.EOF, than no more items left

func (*RestClient) Post

func (rc *RestClient) Post(url string, data io.Reader) (jsonstream []byte, err error)

func (*RestClient) Put

func (rc *RestClient) Put(url string, data io.Reader) (jsonstream []byte, err error)

Jump to

Keyboard shortcuts

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