api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api serves the admin REST API and the editor's event websocket.

Index

Constants

View Source
const (
	PermFlowsRead  = "flows.read"
	PermFlowsWrite = "flows.write"
	PermStatusRead = "status.read"
	PermNodesRead  = "nodes.read"
	PermSettings   = "settings.read"
	PermInject     = "inject.write"
)

Permissions the API checks. Mirrors Node-RED's granular scheme so a read-only dashboard token cannot deploy a flow.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeployResult

type DeployResult struct {
	Rev      string               `json:"rev"`
	Failures []runtime.StartError `json:"-"`
	Warnings []string             `json:"warnings,omitempty"`
}

DeployResult reports what a deploy did.

type Deps

type Deps struct {
	Config      config.Config
	Registry    *node.Registry
	Flows       *store.FlowStore
	Credentials *store.CredentialStore
	Logger      *slog.Logger

	// Runtime returns the currently running runtime. It is a function rather
	// than a value because a deploy replaces the whole runtime, and every
	// handler needs the live one rather than the one that existed at startup.
	Runtime func() *runtime.Runtime

	// Deploy swaps in a new flow set. It owns stopping the old runtime,
	// persisting, and starting the new one.
	Deploy func(ctx context.Context, flows *engine.Flows, expectedRev string) (DeployResult, error)

	// FlowRoutes holds the paths the flow's HTTP In nodes have claimed. It is
	// consulted for anything the fixed routes below did not match, because a
	// flow's routes change on every deploy and http.ServeMux cannot unregister
	// a pattern.
	FlowRoutes *flowhttp.Router

	// Version identifies this build in /settings and the log.
	Version string
}

Deps is everything the server needs from the rest of the process.

type Server

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

Server is the HTTP surface.

func New

func New(deps Deps) *Server

New builds the server and wires its routes.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the root HTTP handler.

func (*Server) Hub

func (s *Server) Hub() *hub

Hub returns the websocket fan-out, so the process can pump runtime events into it.

Jump to

Keyboard shortcuts

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