extensions

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeREST

func ServeREST(registeredExtensions RegisteredExtensions) error

ServeREST serves the registered extension functions as a REST API

func ServeRPC

func ServeRPC(registeredExtensions RegisteredExtensions) error

ServeRPC serves the registered extension functions over RPC

Types

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorResponse is used when an error occurred processing a request

type ExecuteExtensionRequest

type ExecuteExtensionRequest struct {
	FSM       *fsm.FSM        `json:"fsm"`
	Domain    *fsm.BaseDomain `json:"domain"`
	Extension string          `json:"extension"`
	Question  *query.Question `json:"question"`
	Channel   string          `json:"channel"`
	Command   string          `json:"command"`
}

ExecuteExtensionRequest contains the instructions for executing a command function

type ExecuteExtensionResponse

type ExecuteExtensionResponse struct {
	FSM     *fsm.FSM       `json:"fsm"`
	Answers []query.Answer `json:"answers"`
}

ExecuteExtensionResponse contains the result of executing a command function

type GetAllExtensionsRequest

type GetAllExtensionsRequest struct {
}

GetAllExtensionsRequest is empty for now to match RPC interface. Maybe later we will use it for filtering/searching commands

type GetAllExtensionsResponse

type GetAllExtensionsResponse struct {
	Extensions []string
}

GetAllExtensionsResponse contains a list of all registered command functions

type GetBuildVersionRequest

type GetBuildVersionRequest struct {
}

GetBuildVersionRequest is empty for now to match RPC interface.

type ListenerREST

type ListenerREST struct {
	RegisteredExtensions RegisteredExtensions
	// contains filtered or unexported fields
}

ListenerREST contains the RegisteredExtensions to be served through REST

func NewListenerREST

func NewListenerREST(registeredExtensions RegisteredExtensions, token string) *ListenerREST

NewListenerREST creates a ListenerREST with command functions and a token

func (*ListenerREST) ExecuteExtension

func (l *ListenerREST) ExecuteExtension(w http.ResponseWriter, r *http.Request)

ExecuteExtension runs the requested command function and returns the response

func (*ListenerREST) GetAllExtensions

func (l *ListenerREST) GetAllExtensions(w http.ResponseWriter, r *http.Request)

GetAllExtensions returns all command functions in RegisteredExtensions as a list of strings

func (*ListenerREST) GetBuildVersion

func (l *ListenerREST) GetBuildVersion(w http.ResponseWriter, r *http.Request)

GetBuildVersion returns the current build version of the extension

type ListenerRPC

type ListenerRPC struct {
	RegisteredExtensions RegisteredExtensions
}

ListenerRPC contains the RegisteredExtensions to be served through RPC

func (*ListenerRPC) ExecuteExtension

func (l *ListenerRPC) ExecuteExtension(req *ExecuteExtensionRequest, res *ExecuteExtensionResponse) error

ExecuteExtension runs the requested command function and returns the response

func (*ListenerRPC) GetAllExtensions

func (l *ListenerRPC) GetAllExtensions(_ *GetAllExtensionsRequest, res *GetAllExtensionsResponse) error

GetAllExtensions returns all functions registered in the RegisteredExtensions map

func (*ListenerRPC) GetBuildVersion

func (l *ListenerRPC) GetBuildVersion(_ *GetBuildVersionRequest, res *version.BuildResponse) error

GetBuildVersion returns the current build version of the extension

type RegisteredExtensions

type RegisteredExtensions map[string]func(*ExecuteExtensionRequest) *ExecuteExtensionResponse

RegisteredExtensions maps commands to functions which are executed by extension servers

func (*RegisteredExtensions) Get

func (r *RegisteredExtensions) Get() []string

Get returns a list of all registered function command names

Jump to

Keyboard shortcuts

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