http

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultipartFileEntry

type MultipartFileEntry struct {
	Param string
	Path  string
	File  *os.File
}

MultipartFileEntry is a multipart file entry. It is used to map a file to it's field value and label for Multipart requests.

type SimpleClient

type SimpleClient struct {

	// Base is the base to use for all urls. If empty, will use the given urls as is.
	Base string

	// NewRequest allows to customize which http.Request the simple client will use.
	NewRequest func(method, urlStr string, body io.Reader) (*http.Request, error)
}

SimpleClient is a simplified http client

func NewSimpleClient

func NewSimpleClient() *SimpleClient

NewSimpleClient creates a new default client

func (*SimpleClient) Get

func (c *SimpleClient) Get(urlStr string, params url.Values) (*http.Request, *http.Response, error)

Get does an http get

func (*SimpleClient) Multipart

func (c *SimpleClient) Multipart(urlStr string, files map[string]string, get, post url.Values, writeFileCallback WriteFileFunc) (*http.Request, *http.Response, error)

Multipart does a multipart file upload request of type multipart/form-data

func (*SimpleClient) Post

func (c *SimpleClient) Post(urlStr string, get url.Values, post interface{}) (*http.Request, *http.Response, error)

Post does an http post of type application/json

type WriteFileFunc

type WriteFileFunc func(dst io.Writer, src MultipartFileEntry) (int64, error)

WriteFileFunc allows the caller to customize how the file is written. If this is null, a simple io.Copy will be done.

Jump to

Keyboard shortcuts

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