Documentation
¶
Index ¶
- func GetConfig(key string) (string, bool)
- func GetVar(key string) []byte
- func GetVarInt(key string) int
- func Input() []byte
- func InputJSON(v any) error
- func InputString() string
- func JSONFrom(offset uint64, v any) error
- func Log(level LogLevel, s string)
- func LogMemory(level LogLevel, memory Memory)
- func Output(data []byte)
- func OutputJSON(v any) error
- func OutputMemory(mem Memory)
- func OutputString(s string)
- func ParamBytes(offset uint64) []byte
- func ParamString(offset uint64) string
- func ParamU32(offset uint64) uint32
- func ParamU64(offset uint64) uint64
- func RemoveVar(key string)
- func ResultBytes(d []byte) uint64
- func ResultString(s string) uint64
- func ResultU32(d uint32) uint64
- func ResultU64(d uint64) uint64
- func SetError(err error)
- func SetErrorString(err string)
- func SetVar(key string, value []byte)
- func SetVarInt(key string, value int)
- type HTTPMethod
- type HTTPRequest
- type HTTPRequestMeta
- type HTTPResponse
- type LogLevel
- type Memory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InputString ¶
func InputString() string
InputString returns the input data from the host as a UTF-8 string.
func JSONFrom ¶ added in v1.0.2
JSONFrom unmarshals a `Memory` block located at `offset` from the host into the provided data `v`.
func OutputJSON ¶ added in v1.0.2
OutputJSON marshals the provided data `v` as output to the host.
func OutputMemory ¶
func OutputMemory(mem Memory)
OutputMemory sends the `mem` Memory to the host output. Note that the `mem` is _NOT_ freed and is your responsibility to free when finished with it.
func OutputString ¶
func OutputString(s string)
OutputString sends the UTF-8 string `s` to the host output.
func ParamBytes ¶ added in v1.0.3
ParamBytes returns bytes from Extism host memory given an offset.
func ParamString ¶ added in v1.0.3
ParamString returns UTF-8 string data from Extism host memory given an offset.
func RemoveVar ¶
func RemoveVar(key string)
RemoveVar removes (and frees) the host variable associated with `key`.
func ResultBytes ¶ added in v1.0.3
ResultBytes allocates bytes and returns the offset in Extism host memory.
func ResultString ¶ added in v1.0.3
ResultString allocates a UTF-8 string and returns the offset in Extism host memory.
func ResultU32 ¶ added in v1.0.3
ResultU32 allocates a uint32 and returns the offset in Extism host memory.
func ResultU64 ¶ added in v1.0.3
ResultU64 allocates a uint64 and returns the offset in Extism host memory.
func SetErrorString ¶
func SetErrorString(err string)
SetErrorString sets the host error string from `err`.
Types ¶
type HTTPMethod ¶ added in v1.0.1
type HTTPMethod int32
HTTPMethod represents an HTTP method.
const ( MethodGet HTTPMethod = iota MethodHead MethodPost MethodPut MethodPatch // RFC 5789 MethodDelete MethodConnect MethodOptions MethodTrace )
func (HTTPMethod) String ¶ added in v1.0.1
func (m HTTPMethod) String() string
type HTTPRequest ¶
type HTTPRequest struct {
// contains filtered or unexported fields
}
HTTPRequest represents an HTTP request sent by the host.
func NewHTTPRequest ¶
func NewHTTPRequest(method HTTPMethod, url string) *HTTPRequest
NewHTTPRequest returns a new `HTTPRequest`.
func (*HTTPRequest) Send ¶
func (r *HTTPRequest) Send() HTTPResponse
Send sends the `HTTPRequest` from the host and returns the `HTTPResponse`.
func (*HTTPRequest) SetBody ¶
func (r *HTTPRequest) SetBody(body []byte) *HTTPRequest
SetBody sets an HTTP request body to the provided byte slice.
func (*HTTPRequest) SetHeader ¶
func (r *HTTPRequest) SetHeader(key string, value string) *HTTPRequest
SetHeader sets an HTTP header `key` to `value`.
type HTTPRequestMeta ¶
type HTTPRequestMeta struct {
URL string `json:"url"`
Method string `json:"method"`
Headers map[string]string `json:"headers"`
}
HTTPRequestMeta represents the metadata associated with an HTTP request on the host.
type HTTPResponse ¶
type HTTPResponse struct {
// contains filtered or unexported fields
}
HTTPResponse represents an HTTP response returned from the host.
func (HTTPResponse) Body ¶
func (r HTTPResponse) Body() []byte
Body returns the body byte slice (if any) from the `HTTPResponse`.
func (HTTPResponse) Memory ¶
func (r HTTPResponse) Memory() Memory
Memory returns the memory associated with the `HTTPResponse`.
func (HTTPResponse) Status ¶
func (r HTTPResponse) Status() uint16
Status returns the status code from the `HTTPResponse`.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory represents memory allocated by (and shared with) the host.
func AllocateBytes ¶
AllocateBytes allocates and saves the `data` into Memory on the host.
func AllocateJSON ¶ added in v1.0.4
AllocateJSON allocates and saves the type `any` into Memory on the host.
func AllocateString ¶
AllocateString allocates and saves the UTF-8 string `data` into Memory on the host.
func FindMemory ¶
FindMemory finds the host memory block at the given `offset`.
Directories
¶
| Path | Synopsis |
|---|---|
|
example
module
|
|
|
countvowels
command
|
|
|
http
command
|
|
|
reactor
command
|
|
|
wasi-reactor
module
|