requests

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToJsonString

func MapToJsonString(m J) (string, error)

func MapToQueryString

func MapToQueryString(m KV) string

Types

type F

type F struct {
	Filename string
	Buffer   []byte
}

type Files

type Files map[string]F

type GP

type GP struct {
	Params            KV
	Headers           KV
	Cookies           KV
	Proxies           string
	NotAllowRedirects bool
	Timeout           time.Duration
}

type J

type J map[string]interface{}

type KV

type KV map[string]string

func (KV) Get

func (k KV) Get(name string) string

func (KV) Set

func (k KV) Set(name string, value string)

type L

type L []interface{}

type P

type P struct {
	Method            string
	Params            KV
	Data              KV
	DataString        string
	Json              J
	JsonString        string
	Headers           KV
	Cookies           KV
	Files             Files
	Form              KV
	Proxies           string
	NotAllowRedirects bool
	Timeout           time.Duration
}

type PP

type PP struct {
	Params            KV
	Data              KV
	DataString        string
	Json              J
	JsonString        string
	Headers           KV
	Cookies           KV
	Files             Files
	Form              KV
	Proxies           string
	NotAllowRedirects bool
	Timeout           time.Duration
}

type Response

type Response struct {
	Content    []byte
	StatusCode int
	Header     http.Header
	Cookie     []*http.Cookie
}

func Delete

func Delete(url string, gp GP) (*Response, error)

func Get

func Get(url string, gp GP) (*Response, error)

func Post

func Post(url string, pp PP) (*Response, error)

func Put

func Put(url string, pp PP) (*Response, error)

func Request

func Request(url string, p P) (*Response, error)

func (*Response) Json

func (r *Response) Json(result any) error

func (*Response) Text

func (r *Response) Text() string

type Session

type Session struct {
	Headers KV
	Cookies KV
	BaseUrl string
	Timeout time.Duration
	Proxies string
	// contains filtered or unexported fields
}

func NewSession

func NewSession() *Session

func (*Session) Delete

func (s *Session) Delete(url string, gp GP) (*Response, error)

func (*Session) Get

func (s *Session) Get(url string, gp GP) (*Response, error)

func (*Session) Post

func (s *Session) Post(url string, pp PP) (*Response, error)

func (*Session) Put

func (s *Session) Put(url string, pp PP) (*Response, error)

func (*Session) Request

func (session *Session) Request(url string, p P) (*Response, error)

Jump to

Keyboard shortcuts

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