devgw

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 13 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 devgw serves notesd's RPC over a WebSocket on loopback, so the UI can be developed in an ordinary browser against a real notesd (docs/specs/rpc-protocol.md, Transports). notesd serves it only with -devgw. Browsers do not apply CORS to WebSockets, so every connection must carry the token and come from an allowed Origin.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotLoopback = errors.New("devgw: listen address must be loopback")

ErrNotLoopback means the gateway was asked to listen beyond this machine.

View Source
var Origins = []string{"http://127.0.0.1:5173", "http://localhost:5173"}

Origins are the pages allowed to connect: the Vite dev server.

Functions

func BlobHandler

func BlobHandler(token string, store *blobs.Store) http.Handler

BlobHandler serves vault files' contents by their hash, so the UI in a browser shows images, audio and video as the desktop app does through notesblob:// (ADR-0023). A request is GET /blobs/<sha256>.<ext> with the gateway's token as ?token=, since an <img> sends no header the page sets; the extension only names the content type. It answers Range, as audio and video ask (blobhttp).

func ContentType

func ContentType(ext string) string

ContentType returns the media type the app serves a vault file with, by its lower-cased extension (blobhttp.ContentType).

func Handler

func Handler(token string, origins []string, serve func(nc net.Conn)) http.Handler

Handler upgrades requests that carry token (as ?token=) and an Origin in origins, and hands each connection to serve.

func ListenAndServe

func ListenAndServe(ctx context.Context, addr, token string, serve func(nc net.Conn), store *blobs.Store, log *slog.Logger) error

ListenAndServe serves Handler on addr, which must be a loopback address, and BlobHandler over store at /blobs/, until ctx ends.

Types

This section is empty.

Jump to

Keyboard shortcuts

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