chttp

package module
v0.0.0-...-bc19a59 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2017 License: MIT Imports: 7 Imported by: 1

README

chttp

Golang HTTP functional concurrent utilities. (Currently experimental)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Req

type Req interface {
	Client() *http.Client
	RawRequest() *http.Request
	Response() chan Response
	Request() Req
}

func Request

func Request(opts ...RequestOpt) (Req, error)

func RequestOrPanic

func RequestOrPanic(opts ...RequestOpt) Req

type RequestOpt

type RequestOpt func(*http.Client, *http.Request) (*http.Request, error)

func GET

func GET(url string) RequestOpt
func Header(key, value string) RequestOpt

func Oauth

func Oauth(token, secret string) RequestOpt

func POST

func POST(url string, reader io.Reader) RequestOpt

func Timeout

func Timeout(seconds int) RequestOpt

type Response

type Response struct {
	Raw     *http.Response
	Err     error
	Request Req
}

func (Response) ReadAll

func (c Response) ReadAll() (body []byte, err error)

func (Response) ReadJSON

func (c Response) ReadJSON(target interface{}) error

type SimpleReq

type SimpleReq struct {
	C   *http.Client
	Raw *http.Request
}

func (SimpleReq) Client

func (r SimpleReq) Client() *http.Client

func (SimpleReq) RawRequest

func (r SimpleReq) RawRequest() *http.Request

func (SimpleReq) Request

func (r SimpleReq) Request() Req

func (SimpleReq) Response

func (r SimpleReq) Response() chan Response

type SyncPool

type SyncPool struct {
	Workers int
	In      chan<- Req
	Out     <-chan Response
}

func Pool

func Pool(workers, buffers int) (pool SyncPool)

Creates a requests SyncPool with n workers.

func SymmetricPool

func SymmetricPool(n int) SyncPool

Create a symmetric pool (equal workers & buffer capacity).

func (SyncPool) Run

func (pool SyncPool) Run(in chan Req, out chan Response)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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