nethttp

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package nethttp exposes a net/http handler that upgrades incoming requests to WebSocket and hands the resulting connection to a server.Server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler is the http.Handler returned by NewHandler. It is also callable as a graceful shutter via Shutdown.

func NewHandler

func NewHandler(srv *server.Server, opts Options) *Handler

NewHandler returns a Handler that upgrades requests on opts.Path to WebSocket and serves them with srv.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context) error

Shutdown closes every active WebSocket with status 1001 (Going Away) and waits for ctx to expire.

type Options

type Options struct {
	// Path is the request path served by the handler. Defaults to
	// "/arcp"; the handler returns 404 for any other request path
	// when invoked through a parent mux that does not strip the
	// prefix.
	Path string
	// AllowedHosts is the list of acceptable HTTP Host headers. The
	// SDK default is the loopback set per spec §14 DNS-rebind
	// protection.
	AllowedHosts []string
	// ReadLimit caps the inbound WebSocket frame size in bytes. Zero
	// uses 1 MiB.
	ReadLimit int64
	// Subprotocols negotiated with the client. Empty selects none.
	Subprotocols []string
	// Origins allowed for browser clients. nil disables CORS.
	Origins []string
	// PingInterval drives WS-layer keepalives. Zero disables.
	PingInterval time.Duration
}

Options configures the HTTP handler.

Jump to

Keyboard shortcuts

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