flowhttp

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: 6 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 flowhttp routes HTTP requests to the HTTP In nodes in a running flow.

The admin API and the editor are served by a plain http.ServeMux built once at start-up. Flow routes cannot be: they appear and disappear on every deploy, and ServeMux has no way to remove a pattern. So they live here, in a router the API server delegates to for anything the fixed routes did not claim.

Two rules that Node-RED does not have, both because the alternative fails quietly. A flow may not register a path that would shadow the editor or the admin API — the deploy is refused instead, because the symptom otherwise is an editor that stops loading with no explanation. And two nodes may not claim the same method and path; Express runs whichever matched first and the second node simply never fires.

Index

Constants

View Source
const MethodAny = ""

MethodAny matches any request method, which is Node-RED's "all".

Variables

This section is empty.

Functions

func RouteParams

func RouteParams(r *http.Request) map[string]string

RouteParams reads back what WithRouteParams attached. An HTTP In node uses it to fill msg.req.params.

func WithRouteParams

func WithRouteParams(r *http.Request, params map[string]string) *http.Request

WithRouteParams attaches captured path parameters to a request.

Types

type Router

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

Router holds the routes the flow's HTTP In nodes have registered.

func NewRouter

func NewRouter(root string, reserved []string) *Router

NewRouter builds a router serving flow routes under root.

func (*Router) Len

func (r *Router) Len() int

Len reports how many routes are registered.

func (*Router) Match

func (r *Router) Match(method, path string) (http.Handler, map[string]string, bool)

Match finds the handler for a request, along with the path parameters it captured.

func (*Router) Register

func (r *Router) Register(nodeID, method, pattern string, h http.Handler) (func(), error)

Register adds a route and returns the function that removes it again, which is what an HTTP In node calls on Close.

The method is one of the usual verbs, or MethodAny.

func (*Router) Reset

func (r *Router) Reset()

Reset drops every route. Called when a runtime is torn down, so a node that failed to close cannot leave a route pointing at a dead flow.

func (*Router) Root

func (r *Router) Root() string

Root is the prefix flow routes are served under.

Jump to

Keyboard shortcuts

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