weblib

package
v0.0.0-...-6c37ce1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 10 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware(allowedOrigins []string, next http.Handler) http.Handler

CORSMiddleware permits cross-origin requests with credentials for local/UI deployments.

func ReadJSON

func ReadJSON(r *http.Request, dst any) error

ReadJSON decodes JSON from r.Body into dst with a 16 MiB safety bound.

func SPAHandler

func SPAHandler(distDir, mountPrefix string) http.Handler

SPAHandler serves a built Vite/React SPA directory (distDir) under mountPrefix (e.g. "/ui"), serving static files directly and falling back to index.html for client-side routes.

func WriteError

func WriteError(w http.ResponseWriter, status int, msg string)

WriteError encodes a FastAPI-compatible `{"detail": msg}` JSON error response.

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, v any)

WriteJSON encodes v as JSON with the given HTTP status code.

Types

type WSConn

type WSConn struct {
	Conn *websocket.Conn
}

WSConn wraps coder/websocket.Conn with ergonomic JSON helpers.

func AcceptWebSocket

func AcceptWebSocket(w http.ResponseWriter, r *http.Request) (*WSConn, error)

AcceptWebSocket upgrades an HTTP request to an RFC 6455 WebSocket connection.

func (*WSConn) Close

func (ws *WSConn) Close() error

Close closes the WebSocket normally.

func (*WSConn) ReadJSON

func (ws *WSConn) ReadJSON(ctx context.Context, dst any) error

ReadJSON reads a JSON message from the WebSocket.

func (*WSConn) WriteJSON

func (ws *WSConn) WriteJSON(ctx context.Context, v any) error

WriteJSON writes a JSON message to the WebSocket.

Jump to

Keyboard shortcuts

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