ipc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	EventName string `json:"event"`
	Data      any    `json:"data"`
}

Event is a push message from Go to JS (no request ID).

type HandlerFunc

type HandlerFunc func(params json.RawMessage) (any, error)

HandlerFunc processes an IPC request and returns a result or error.

type Request

type Request struct {
	ID     string          `json:"id"`
	Method string          `json:"method"`
	Params json.RawMessage `json:"params"`
}

Request is a message from JS to Go.

type Response

type Response struct {
	ID     string `json:"id"`
	Result any    `json:"result"`
	Error  string `json:"error,omitempty"`
}

Response is a message from Go to JS.

type Router

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

Router routes IPC method calls to handler functions.

func NewRouter

func NewRouter() *Router

NewRouter creates a new IPC router.

func SetupRouter

func SetupRouter() *Router

SetupRouter creates and returns a router with no handlers registered. API handlers are registered by calling router.Handle() from each api package.

func (*Router) Handle

func (r *Router) Handle(method string, handler HandlerFunc)

Handle registers a handler for a method name.

func (*Router) HandleMessage

func (r *Router) HandleMessage(rawMsg string) string

HandleMessage processes a raw JSON message from the webview and returns the JSON response.

func (*Router) SendEvent

func (r *Router) SendEvent(eventName string, data any)

SendEvent sends an event to the webview via JS eval.

func (*Router) SetEvalFunc

func (r *Router) SetEvalFunc(fn func(js string))

SetEvalFunc sets the function used to send JS to the webview.

Jump to

Keyboard shortcuts

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