hc

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = NewClient(http.DefaultClient)

DefaultClient is the default Client.

Functions

This section is empty.

Types

type BodyParser

type BodyParser func(*http.Response) (interface{}, error)

type Client

type Client interface {
	// Do sends an HTTP request and returns a response Mono.
	Do(req *http.Request, opts ...Option) Mono
	// Get sends a GET request and returns a response Mono.
	Get(url string, opts ...Option) Mono
	// Delete sends a DELETE request and returns a response Mono.
	Delete(url string, opts ...Option) Mono
	// Post sends a POST request and returns a response Mono.
	Post(url string, contentType string, body io.Reader, opts ...Option) Mono
	// Put sends a PUT request and returns a response Mono.
	Put(url string, contentType string, body io.Reader, opts ...Option) Mono
	// Patch sends a PATCH request and returns a response Mono.
	Patch(url string, contentType string, body io.Reader, opts ...Option) Mono
}

Client is a reactor style http client which returns a Mono.

func NewClient

func NewClient(cli *http.Client, defaultOptions ...Option) Client

NewClient creates a new Client.

type Mono

type Mono = mono.Mono

Mono is alias of mono.Mono.

func Delete

func Delete(url string, opts ...Option) Mono

Delete sends a DELETE request and returns a response Mono.

func Do

func Do(req *http.Request, opts ...Option) Mono

Do sends an HTTP request and returns a response Mono.

func Get

func Get(url string, opts ...Option) Mono

Get sends a GET request and returns a response Mono.

func Patch

func Patch(url string, contentType string, body io.Reader, opts ...Option) Mono

Patch sends a PATCH request and returns a response Mono.

func Post

func Post(url string, contentType string, body io.Reader, opts ...Option) Mono

Post sends a POST request and returns a response Mono.

func Put

func Put(url string, contentType string, body io.Reader, opts ...Option) Mono

Put sends a PUT request and returns a response Mono.

type Option

type Option func(*option)

Option is the type of http client options.

func WithJSONResponse

func WithJSONResponse(gen func() (ptr interface{})) Option

WithJSONResponse decodes the response body as json.

func WithRequestHijack

func WithRequestHijack(h func(*http.Request)) Option

WithRequestHijack can be used to customize the http request.

func WithResponseBodyParser

func WithResponseBodyParser(bp BodyParser) Option

WithResponseBodyParser set the response body parser.

func WithStringResponse

func WithStringResponse() Option

WithStringResponse decodes the response body as string.

Jump to

Keyboard shortcuts

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