nethttp

package module
Version: v0.0.0-...-4f030cb Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

README

starlark-go-nethttp

A wrapper around a minimal subset of net/http package for use within starlark-go.

Documentation

Getting started

Build the code:

# check out the code and dependencies,
# and install interpreter in $GOPATH/bin
$ go get -u github.com/pcj/starlark-go-nethttp

Run the interpreter or interact with the read-eval-print loop (REPL):

$ nethttp
>>> resp = http.get("https://google.com")
>>> resp.code
200
>>>

When you have finished, type Ctrl-D to close the REPL's input stream.

Embedding

To embed the module within your own configuration language, add it to your globals:

globals := starlark.StringDict{
    "http": nethttp.NewModule(),
}
Contributing

Contributions welcome.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHttpRequestAttrs

func GetHttpRequestAttrs(request *http.Request) (*starlark.StringDict, error)

Types

type HttpRequest

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

func AsHttpRequest

func AsHttpRequest(value starlark.Value) (*HttpRequest, bool)

AsHttpRequest attempts a type assertion and returns the typed request or False if the type assertion failed.

func NewHttpRequest

func NewHttpRequest(request *http.Request) (*HttpRequest, error)

func (*HttpRequest) Attr

func (r *HttpRequest) Attr(name string) (starlark.Value, error)

func (*HttpRequest) AttrNames

func (r *HttpRequest) AttrNames() []string

func (*HttpRequest) Freeze

func (r *HttpRequest) Freeze()

func (*HttpRequest) Hash

func (r *HttpRequest) Hash() (uint32, error)

func (*HttpRequest) String

func (r *HttpRequest) String() string

func (*HttpRequest) Truth

func (r *HttpRequest) Truth() starlark.Bool

func (*HttpRequest) Type

func (r *HttpRequest) Type() string

type Module

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

func NewModule

func NewModule() *Module

NewModule constructs the module instance that can be added to the global scope.

func (*Module) Attr

func (mod *Module) Attr(name string) (starlark.Value, error)

func (*Module) AttrNames

func (mod *Module) AttrNames() []string

func (*Module) Freeze

func (mod *Module) Freeze()

func (*Module) Hash

func (mod *Module) Hash() (uint32, error)

func (*Module) String

func (mod *Module) String() string

func (*Module) Truth

func (mod *Module) Truth() starlark.Bool

func (*Module) Type

func (mod *Module) Type() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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