Documentation
¶
Overview ¶
Package capsule SDK for WASM plugin
Index ¶
- func CacheDel(key string) []byte
- func CacheGet(key string) ([]byte, error)
- func CacheKeys(filter string) ([]string, error)
- func CacheSet(key string, value []byte) []byte
- func CopyBufferToMemory(buffer []byte) uint64
- func Failure(buffer []byte) uint64
- func GetEnv(variableName string) string
- func GetHeaders(headers string) map[string]string
- func Log(message string)
- func Print(message string)
- func ReadBufferFromMemory(bufferPosition *uint32, length uint32) []byte
- func ReadFile(filePath string) ([]byte, error)
- func RedisDel(key string) ([]byte, error)
- func RedisGet(key string) ([]byte, error)
- func RedisKeys(filter string) ([]string, error)
- func RedisSet(key string, value []byte) ([]byte, error)
- func Result(data []byte) ([]byte, error)
- func SetHandle(function func(param []byte) ([]byte, error))
- func SetHandleHTTP(function func(param HTTPRequest) (HTTPResponse, error))
- func SetHandleJSON(function func(param *fastjson.Value) ([]byte, error))
- func SetHeaders(headers map[string]string) string
- func StringifyHTTPResponse(response HTTPResponse) string
- func Success(buffer []byte) uint64
- func Talk(bufferMessageToHost []byte) []byte
- func WriteFile(filePath string, content []byte) error
- type HTTPRequest
- type HTTPResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyBufferToMemory ¶
CopyBufferToMemory returns a single value
func GetHeaders ¶ added in v0.0.5
GetHeaders return a map of headers from a string of headers transform a JSON string to a map[string]string
func ReadBufferFromMemory ¶
ReadBufferFromMemory returns a buffer
func RedisDel ¶ added in v0.0.2
RedisDel deletes a Redis key and returns the result as a slice of bytes. The key parameter is a string representing the key to be deleted. The function returns a slice of bytes and an error.
func RedisGet ¶ added in v0.0.2
RedisGet retrieves the value for the given key from Redis.
It takes a single string parameter, `key`, which is used to identify the value to retrieve from Redis.
RedisGet returns a slice of bytes containing the retrieved value, and an error if the retrieval failed or the key was not found.
func RedisKeys ¶ added in v0.0.2
RedisKeys returns an array of Redis keys that match the given filter.
filter: A string used to filter Redis keys. Returns an array of strings and an error.
func RedisSet ¶ added in v0.0.2
RedisSet sends a message to the host to cache a key and its value.
key: the string value of the key to cache. value: the byte slice value to cache. []byte: a byte slice that contains the response from the host.
func SetHandleHTTP ¶
func SetHandleHTTP(function func(param HTTPRequest) (HTTPResponse, error))
SetHandleHTTP sets the handle function
func SetHandleJSON ¶
SetHandleJSON sets the handle function
func SetHeaders ¶ added in v0.0.5
SetHeaders return a string of headers from a map of headers transform a map[string]string to a JSON string
func StringifyHTTPResponse ¶ added in v0.0.4
func StringifyHTTPResponse(response HTTPResponse) string
StringifyHTTPResponse converts a HTTPResponse to a string
Types ¶
type HTTPRequest ¶
type HTTPRequest struct {
Body string
JSONBody string
TextBody string
URI string
Method string
Headers string
}
HTTPRequest is the data of the http request
type HTTPResponse ¶
type HTTPResponse struct {
//Body string
JSONBody string
TextBody string
Headers string
StatusCode int
}
HTTPResponse is the data of the http response
func HTTP ¶
func HTTP(request HTTPRequest) (HTTPResponse, error)
HTTP is an helper to use the hostHTTP function