xhr

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextType   string = "text/plain"
	JSONType   string = "application/json"
	StreamType string = "application/octet-stream"
)

content types

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client ...

func Delete

func Delete(url string, data ...interface{}) *Client

Delete ...

func Get

func Get(url string, data ...interface{}) *Client

Get ...

func NewClient

func NewClient() *Client

NewClient returns Client

func Post

func Post(url string, data ...interface{}) *Client

Post ...

func Put

func Put(url string, data ...interface{}) *Client

Put ...

func (*Client) Always

func (cli *Client) Always(cb func(*Response)) *Client

Always ...

func (*Client) Do

func (cli *Client) Do(req *Request) *Client

Do ...

func (*Client) Done

func (cli *Client) Done(cb func(*Response)) *Client

Done ...

func (*Client) Fail

func (cli *Client) Fail(cb func(*Response)) *Client

Fail ...

func (*Client) JSValue

func (cli *Client) JSValue() js.Value

JSValue ...

func (*Client) LastErr

func (cli *Client) LastErr() error

LastErr ...

func (*Client) Progress

func (cli *Client) Progress(cb func(int, int, bool)) *Client

Progress ...

type Request

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

Request ...

func NewRequest

func NewRequest(method, url string, body []byte) *Request

NewRequest returns a request.

func (*Request) SetHeader

func (req *Request) SetHeader(key, value string) *Request

SetHeader set request header.

type Response

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

Response ...

func (*Response) Body

func (resp *Response) Body() []byte

Body ...

func (*Response) Code

func (resp *Response) Code() int

Code ...

func (*Response) GetHeader

func (resp *Response) GetHeader(key string) string

GetHeader ...

func (*Response) String

func (resp *Response) String() string

type State

type State int

State xhr state

const (
	Unsent          State = 0
	Opened          State = 1
	HeadersReceived State = 2
	Loading         State = 3
	Done            State = 4
)

ReadyState ...

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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