Documentation
¶
Overview ¶
Package web implements the obx HTTP server: a browser-based Oberon+ editor (GET /) backed by a JSON API (POST /api/check, GET /api/version).
CORS is enabled on every route so the API can be consumed by external editors, scripts, and CI tooling without proxy configuration.
Index ¶
- func Start(cfg Config) error
- type Config
- type Server
- func (s *Server) HandleCFG(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleCheck(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleStatic(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleUI(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleVersion(w http.ResponseWriter, _ *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Addr string // host:port to listen on, e.g. ":8080"
MaxErrors int // max errors before the pipeline stops
// Timeouts (defaults are set in the CLI and Start)
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
// Rate limiting (requests per second and burst)
RateLimit float64
RateLimitBurst int
// AdminAddr binds a localhost-only admin listener for metrics/diagnostics (e.g. "127.0.0.1:9090").
AdminAddr string
// Request limits (bytes / characters)
MaxBodyBytes int // maximum allowed request body bytes for JSON endpoints
MaxSourceBytes int // maximum allowed length of the 'source' payload
MaxFilenameLen int // maximum length of submitted filenames
// CORS / auth
AllowedOrigins []string // allowed CORS origins (empty = deny all cross-origin)
APIKey string // optional API key accepted via X-API-Key header
// JWTSecret, when set, enables HMAC-SHA256 (HS256) bearer token auth for API endpoints.
JWTSecret string
}
Config holds all runtime parameters for the web server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server owns the mux and carries Config so every handler can read it.
func (*Server) HandleCFG ¶
func (s *Server) HandleCFG(w http.ResponseWriter, r *http.Request)
HandleCFG runs the full front-end pipeline (parse → sema → desugar → ObxIR) and returns a Graphviz DOT string for each function's CFG.
func (*Server) HandleCheck ¶
func (s *Server) HandleCheck(w http.ResponseWriter, r *http.Request)
func (*Server) HandleRun ¶
func (s *Server) HandleRun(w http.ResponseWriter, r *http.Request)
HandleRun executes the user's program (MVP placeholder). Returns diagnostics and a textual output. Real execution/sandboxing is planned for later.
func (*Server) HandleStatic ¶
func (s *Server) HandleStatic(w http.ResponseWriter, r *http.Request)
HandleStatic serves embedded static files under the `static/` directory. It is a generic safe handler that cleans the requested path, prevents directory traversal, and sets an appropriate Content-Type based on the file extension (falling back to content-sniffing when necessary).
func (*Server) HandleVersion ¶
func (s *Server) HandleVersion(w http.ResponseWriter, _ *http.Request)