fetch

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache string
const (
	CacheDefault      Cache = "default"
	CacheNoStore      Cache = "no-store"
	CacheReload       Cache = "reload"
	CacheNone         Cache = "no-cache"
	CacheForce        Cache = "force-cache"
	CacheOnlyIfCached Cache = "only-if-cached"
)

func (Cache) String

func (cache Cache) String() string

type Credentials

type Credentials string
const (
	CredentialsOmit       Credentials = "omit"
	CredentialsSameOrigin Credentials = "same-origin"
	CredentialsInclude    Credentials = "include"
)

func (Credentials) String

func (credentials Credentials) String() string

type Headers

type Headers map[string][]string

func (Headers) Append

func (headers Headers) Append(key string, value string)

func (Headers) Delete

func (headers Headers) Delete(key string)

func (Headers) Get

func (headers Headers) Get(key string) string

func (Headers) Has

func (headers Headers) Has(key string) bool

func (Headers) Set

func (headers Headers) Set(key string, value string)

func (Headers) Write

func (headers Headers) Write(writer io.Writer) error

type Method

type Method string
const (
	MethodConnect Method = "CONNECT"
	MethodDelete  Method = "DELETE"
	MethodGet     Method = "GET"
	MethodHead    Method = "HEAD"
	MethodOptions Method = "OPTIONS"
	MethodPatch   Method = "PATCH"
	MethodPost    Method = "POST"
	MethodPut     Method = "PUT"
	MethodTrace   Method = "TRACE"
)

func (Method) String

func (method Method) String() string

type Mode

type Mode string
const (
	ModeSameOrigin Mode = "same-origin"
	ModeNoCORS     Mode = "no-cors"
	ModeCORS       Mode = "cors"
	ModeNavigate   Mode = "navigate"
)

func (Mode) String

func (mode Mode) String() string

type Redirect

type Redirect string
const (
	RedirectFollow Redirect = "follow"
	RedirectError  Redirect = "error"
	RedirectManual Redirect = "manual"
)

func (Redirect) String

func (redirect Redirect) String() string

type ReferrerPolicy

type ReferrerPolicy string
const (
	ReferrerPolicyNone                        ReferrerPolicy = "no-referrer"
	ReferrerPolicyNoDowngrade                 ReferrerPolicy = "no-referrer-when-downgrade"
	ReferrerPolicyOrigin                      ReferrerPolicy = "origin"
	ReferrerPolicyOriginWhenCrossOrigin       ReferrerPolicy = "origin-when-cross-origin"
	ReferrerPolicySameOrigin                  ReferrerPolicy = "same-origin"
	ReferrerPolicyStrictOrigin                ReferrerPolicy = "strict-origin"
	ReferrerPolicyStrictOriginWhenCrossOrigin ReferrerPolicy = "strict-origin-when-cross-origin"
	ReferrerPolicyUnsafeURL                   ReferrerPolicy = "unsafe-url"
)

type Request

type Request struct {
	Method         Method            `json:"method"`
	Headers        map[string]string `json:"headers"`
	Body           io.Reader         `json:"body"`
	Mode           Mode              `json:"mode"`
	Credentials    Credentials       `json:"credentials"`
	Cache          Cache             `json:"cache"`
	Redirect       Redirect          `json:"redirect"`
	Referrer       string            `json:"referrer"`
	ReferrerPolicy string            `json:"referrerPolicy"`
	Integrity      string            `json:"integrity"`
	KeepAlive      bool              `json:"keepalive"`
	Signal         context.Context
}

func (*Request) MapToJS

func (request *Request) MapToJS() map[string]any

type Response

type Response struct {
	Headers    Headers `json:"headers"`
	OK         bool    `json:"ok"`
	Redirected bool    `json:"redirected"`
	Status     int     `json:"status"`
	StatusText string  `json:"statusText"`
	Type       string  `json:"type"`
	URL        string  `json:"url"`
	Body       []byte  `json:"body"`
	BodyUsed   bool    `json:"bodyUsed"`
	Value      *js.Value
}

func Fetch

func Fetch(url string, request *Request) (*Response, error)

func ToResponse

func ToResponse(value js.Value) *Response

Jump to

Keyboard shortcuts

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