devgw

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 11 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 maild's RPC over a WebSocket on loopback, so the UI can be developed in an ordinary browser against a real maild (docs/design/app.md, Dev and test). maild 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 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), log *slog.Logger) error

ListenAndServe serves Handler on addr, which must be a loopback address, 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