rest

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package rest provides an HTTP/SSE gateway that bridges a DDS participant to HTTP clients.

Subscribers receive a real-time Server-Sent Events (SSE) stream over GET /topics/{topic}; publishers POST raw bytes to /topics/{topic}; and GET /topics lists all currently-subscribed topics as JSON.

Usage:

p, _ := rtps.New(dds.Domain(0))
bridge := rest.New(p, rest.Options{})
http.ListenAndServe(":8090", bridge)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

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

Bridge exposes a DDS participant over HTTP. It is safe for concurrent use.

func New

func New(p dds.Participant, opts Options) *Bridge

New creates a Bridge wrapping p. Subscribers and publishers are created lazily on first request.

func (*Bridge) Close

func (b *Bridge) Close() error

Close closes the Bridge and all open subscribers and publishers.

func (*Bridge) ServeHTTP

func (b *Bridge) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes incoming requests:

GET  /topics        → JSON list of subscribed topics
GET  /topics/{t}   → SSE stream of samples on topic t
POST /topics/{t}   → publish request body as a sample on topic t

type Options

type Options struct {
	// AuthToken, if non-empty, requires every request to carry the header
	//   Authorization: Bearer <AuthToken>
	// Requests without a valid token receive 401 Unauthorized.
	AuthToken string

	// QoS is applied to all subscribers and publishers created by the bridge.
	// Zero value uses dds.DefaultQoS.
	QoS dds.QoS

	// SSEKeepalive is how often a comment (:keepalive) line is written to idle
	// SSE streams to prevent proxy timeouts. Default: 15s. Zero disables.
	SSEKeepalive time.Duration
}

Options configures a Bridge.

Jump to

Keyboard shortcuts

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