Documentation ¶
Index ¶
- Constants
- func AsString(x starlark.Value) (string, error)
- func LoadModule() (starlark.StringDict, error)
- func SetBody(req *http.Request, body starlark.String, formData *starlark.Dict, ...) error
- type Module
- type RequestGuard
- type Response
- func (r *Response) HeadersDict() *starlark.Dict
- func (r *Response) JSON(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func (r *Response) Struct() *starlarkstruct.Struct
- func (r *Response) Text(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
Constants ¶
View Source
const ModuleName = "http.star"
ModuleName defines the expected name for this Module when used in starlark's load() function, eg: load('http.star', 'http')
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module joins http tools to a dataset, allowing dataset to follow along with http requests
func (*Module) StringDict ¶
func (m *Module) StringDict() starlark.StringDict
StringDict returns all module methods in a starlark.StringDict
func (*Module) Struct ¶
func (m *Module) Struct() *starlarkstruct.Struct
Struct returns this module's methods as a starlark Struct
type RequestGuard ¶
type RequestGuard interface {
Allowed(thread *starlark.Thread, req *http.Request) (*http.Request, error)
}
RequestGuard controls access to http by checking before making requests if Allowed returns an error the request will be denied
var ( // StarlarkHTTPClient is the http client used to create the http module. override with // a custom client before calling LoadModule StarlarkHTTPClient = http.DefaultClient // StarlarkHTTPGuard is a global RequestGuard used in LoadModule. override with a custom // implementation before calling LoadModule StarlarkHTTPGuard RequestGuard )
type Response ¶
Response represents an HTTP response, wrapping a go http.Response with starlark methods
func (*Response) JSON ¶
func (r *Response) JSON(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
JSON attempts to parse the response body as JSON
func (*Response) Struct ¶
func (r *Response) Struct() *starlarkstruct.Struct
Struct turns a response into a *starlark.Struct
Click to show internal directories.
Click to hide internal directories.