httpc

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoRequest

func DoRequest(r *http.Request) (*http.Response, error)

DoRequest sends an HTTP request and returns an HTTP response.

func Parse

func Parse(resp *http.Response, val interface{}) error

Parse parses the response.

func ParseHeaders

func ParseHeaders(resp *http.Response, val interface{}) error

ParseHeaders parses the rsponse headers.

func ParseJsonBody

func ParseJsonBody(resp *http.Response, val interface{}) error

ParseJsonBody parses the rsponse body, which should be in json content type.

Types

type Option

type Option func(r *http.Request) *http.Request

Option is used to customize the *http.Client.

type Service

type Service interface {
	// DoRequest sends a HTTP request to the service.
	DoRequest(r *http.Request) (*http.Response, error)
}

Service represents a remote HTTP service.

func NewService

func NewService(name string, opts ...Option) Service

NewService returns a remote service with the given name. opts are used to customize the *http.Client.

func NewServiceWithClient

func NewServiceWithClient(name string, cli *http.Client, opts ...Option) Service

NewServiceWithClient returns a remote service with the given name. opts are used to customize the *http.Client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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