fetch

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAccept

func WithAccept(accept string) func(*Request)

func WithAcceptLanguage

func WithAcceptLanguage(acceptLanguage string) func(*Request)

func WithAllowType

func WithAllowType(allowType []string) func(*Request)

func WithLimit

func WithLimit(limit int64) func(*Request)

func WithUserAgent

func WithUserAgent(userAgent string) func(*Request)

Types

type Client

type Client struct {
	HTTPClient *http.Client
}

func NewClient

func NewClient(c ClientOpts) *Client

NewClient は Client を作成する

プライベートIPを許可する場合は http.DefaultClient を返し、 許可しない場合は独自の Client を返す

func (*Client) NewRequest

func (c *Client) NewRequest(url *url.URL, options ...Option) *Request

NewRequest は *Request を返す

type ClientOpts

type ClientOpts struct {
	AllowPrivateIP bool
	Timeout        time.Duration
}

type Option

type Option func(*Request)

type Request

type Request struct {
	// contains filtered or unexported fields
}

func (*Request) Do

func (reqs *Request) Do() ([]byte, error)

Do は指定の url からBodyを取得する

func (*Request) GetHtmlNode

func (reqs *Request) GetHtmlNode() (*html.Node, error)

GetHtmlNode は指定の url から Body を取得し、 html.Node を返す

func (*Request) GetJSON

func (reqs *Request) GetJSON(out any) error

GetJSON は指定の url から Body を取得し、 out に decode する

Jump to

Keyboard shortcuts

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