guiapi

package
v0.0.0-...-68f52cc Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID   int    `json:",omitempty"` // ID can be used from the client to identify responses
	Name string // Name of the action that is called
	// Args as object, gets parsed by the called function
	Args json.RawMessage `json:",omitempty"`
}

type Callable

type Callable func(args json.RawMessage) (*Result, error)

type Error

type Error struct {
	Code    string
	Message string
}

type HTMLOp

type HTMLOp int8
const (
	HTMLReplace HTMLOp = iota + 1
	HTMLDelete
	HTMLAppend
	HTMLPrepend
)

type HTMLUpdate

type HTMLUpdate struct {
	Operation HTMLOp // how to apply this update
	Selector  string // jQuery style selector: #id .class
	Content   string `json:",omitempty"` // inner HTML
	// Init calls are executed after the HTML is added
	Init []JSCall `json:",omitempty"`
	// Destroy calls are executed before the HTML is removed
	Destroy []JSCall `json:",omitempty"`
}

type Handler

type Handler struct {
	Functions map[string]Callable
}

func Handlers

func Handlers() Handler

func (Handler) Handle

func (h Handler) Handle(req *Request) *Response

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type JSCall

type JSCall struct {
	Name string // name of the function to call
	// Arguments as object, gets encoded by the called function
	Arguments json.RawMessage `json:",omitempty"`
}

type Request

type Request struct {
	Actions []Action
}

Request is the sent body of a GUI API call

type Response

type Response struct {
	Results []Result
}

Response is the returned body of a GUI API call

type Result

type Result struct {
	ID    int          `json:",omitempty"` // ID from the calling action is returned
	Name  string       // Name of the action that was called
	Error *Error       `json:",omitempty"`
	HTML  []HTMLUpdate `json:",omitempty"` // DOM updates to apply
	JS    []JSCall     `json:",omitempty"` // JS calls to execute
}

Jump to

Keyboard shortcuts

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