cfgo

package
v0.0.0-...-8f0a20d Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Router = routeHandler{}

Functions

func Fetch

func Fetch(url string, method string, headers map[string]string, requestBody FetchBody) string

Fetches any URL using the fetch() Web API. Unlike browsers, CloudFlare workers miss some features like credentials.

If you don't need headers or a request body, set them to nil:

Fetch(myUrl, "GET", nil, nil)

To create a POST/PUT body, use cfgo.BodyForm() or cfgo.BodyString():

Fetch(myURL, "PUT", nil, cfgo.BodyForm(myDict))

Types

type FetchBody

type FetchBody interface {
	Get() js.Value
}

func BodyForm

func BodyForm(body map[string]string) FetchBody

func BodyString

func BodyString(body string) FetchBody

type KVNamespace

type KVNamespace struct {
	Name string
}

func KV

func KV(namespace string) KVNamespace

func (KVNamespace) GetKey

func (namespace KVNamespace) GetKey(key string) string

func (KVNamespace) ListKeyValues

func (namespace KVNamespace) ListKeyValues(prefix string) map[string]string

func (KVNamespace) PutKey

func (namespace KVNamespace) PutKey(key string, value string)

func (KVNamespace) PutKeyExpiring

func (namespace KVNamespace) PutKeyExpiring(key string, value string, seconds int)

type Request

type Request struct {
	Body        string
	Headers     map[string]string
	QueryParams map[string]string
	URL         string
	Hostname    string
	Pathname    string
	Method      string
	Cf          RequestCFInfo
	// contains filtered or unexported fields
}

func (*Request) Respond

func (r *Request) Respond(body string, options ...ResponseOption)

type RequestCFInfo

type RequestCFInfo struct {
	Asn             string
	Colo            string
	Country         string
	HttpProtocol    string
	RequestPriority string
	TLSCipher       string
	TLSClientAuth   string
	TLSVersion      string
	City            string
	Continent       string
	Latitude        string
	Longitude       string
	PostalCode      string
	MetroCode       string
	Region          string
	RegionCode      string
	Timezone        string
}

type ResponseOption

type ResponseOption interface {
	Apply(responseStruct *responseStruct)
}

func SetHeader

func SetHeader(key string, value string) ResponseOption

func SetStatus

func SetStatus(code int) ResponseOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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