Documentation
¶
Overview ¶
Package webserver is the optional cryptolab web console backend: a self-contained HTTP server that stages uploaded files, runs a selected cryptolab tool/mode with form-supplied settings, streams progress, and returns the structured Result and any artifacts. It is the browser counterpart to the `cryptolab` CLI.
It is imported only by the tag-gated `cryptolab serve` command, so it is never linked into the default gophertrunk binary. It depends only on the cryptolab engine package and the standard library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Assets is the embedded SPA file system (served at /). Nil serves the
// API only with a short placeholder at /.
Assets fs.FS
// TempDir stages uploads and job artifacts. Empty ⇒ a fresh temp dir the
// server owns and removes on Close.
TempDir string
// MaxUploadBytes bounds one upload. 0 ⇒ 512 MiB.
MaxUploadBytes int64
// Logger receives server-level logs. Nil ⇒ slog.Default.
Logger *slog.Logger
}
Options configure a Server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the cryptolab web console HTTP handler.
func New ¶
New constructs a Server. The staging temp directory is created lazily on the first upload/run (not at construction), so merely registering the routes — as the daemon does for every request mux — costs nothing on disk.
func (*Server) Handler ¶
Handler returns a standalone HTTP mux: the cryptolab API plus the embedded SPA at /. Used by `cryptolab serve`.
func (*Server) RegisterAPI ¶
func (s *Server) RegisterAPI(mux *http.ServeMux, gate func(http.HandlerFunc) http.HandlerFunc)
RegisterAPI mounts the /api/v1/cryptolab/* routes onto mux. Mutating routes (file upload, run) are wrapped with gate when non-nil, so the daemon can apply the same auth middleware it uses for its other write routes; the standalone server passes nil. This lets the same service back both the standalone `cryptolab serve` and the daemon-mounted console at /cryptolab/.