http

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(r *Request) (string, error)

Exec sends the passed request object.

@callable: http.Exec @param: r @Request @retval: response @string @retval: err @Error

@usage: resp, err = http.Exec(r)

func Include

func Include() script.Option

Include the http library in a script environment.

func Library

func Library() script.Library

Library prepares a new http library for use within a script environment.

func SetBody

func SetBody(r *Request, value string)

SetBody sets the http body to the value passed on the request object.

@callable: http.SetBody @param: r @Request @param: value @string

@usage: http.SetBody(r, "{key: value}")

func SetHeader

func SetHeader(r *Request, header string, value string)

SetHeader sets the http header to the value passed on the request object.

@callable: http.SetHeader @param: r @Request @param: header @string @param: value @string

@usage: http.SetHeader(r, "Content-Type", "application/json")

func SetMethod

func SetMethod(r *Request, method string)

SetMethod sets the http method on the request object.

@callable: http.SetMethod @param: r @Request @param: method @string

@usage: http.SetMethod(r, "POST")

Types

type Request

type Request struct {
	Url     string
	Method  string
	Headers map[string]string
	Body    string
}

Request provides a concurrency-safe wrapper for an HTTPRequest that implements a starlark.Value.

func NewRequest

func NewRequest(url string) *Request

NewRequest creates a new Request object to be passed around.

@callable: http.NewRequest @param: url @String @retval: request @Request

@usage: r = http.NewRequest(CDN_URL+"/l/nomnom")

func ParseParam

func ParseParam(parser script.ArgParser, index int) (*Request, error)

ParseParam from starlark input

func (Request) Freeze

func (r Request) Freeze()

Freeze is a no-op since the underlying Request is safe for concurrent use.

func (Request) Hash

func (r Request) Hash() (uint32, error)

Hash will error since the Request type is not intended to be hashable.

func (Request) String

func (r Request) String() string

String returns Request metadata.

func (Request) Truth

func (r Request) Truth() starlark.Bool

Truth value of a Request is True if the PID is non-negative

func (Request) Type

func (r Request) Type() string

Type returns 'httprequest' to indicate the type of the Request within starlark.

Jump to

Keyboard shortcuts

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