VEB REUSE 1 1 PLAN
vhttpd 1.1: veb Reuse Plan
Goal
Maximize veb reuse in vhttpd without breaking vslim’s runtime route model.
Reuse Boundary
vhttpdshould heavily reusevebfor HTTP serving concerns.vslimshould keep runtime route registration/dispatch in userland (PHP-driven), not compile-timevebroutes.
This boundary is intentional:
vebroute annotations are compile-time.vslimroutes (App->get/group/middleware) are runtime.
What We Already Reuse
- route attributes with method constraints and wildcard path:
@['/admin/workers'; get]@['/:path...'; get/post/... ]
- middleware chain (
veb.Middleware) andrequest_idmiddleware - SSE streaming helpers (
veb.sse) plus takeover patterns veb.run_atas process entrypoint
High-Value Reuse (P0)
- Controller split for route domains (
register_controller)
- target: split data plane and admin plane handlers into clearer controller structs
- benefit: cleaner ownership, easier review and test isolation
- Route-scoped middleware (
route_use)
- target: attach auth/token checks and observability middleware only to
/admin/* - benefit: avoid broad middleware side effects
- Context lifecycle hook (
before_request)
- target: central request pre-processing (trace propagation defaults, request shaping)
- benefit: reduce duplicated setup code in handlers
Context.not_foundoverride
- target: unify 404 contract and logging for both data/admin plane
- benefit: stable error semantics for clients and tests
Mid-Value Reuse (P1)
veb.csrffor admin web form endpoints (if/when UI forms exist)
- use
csrf.middlewareonly on state-changing admin form routes
- Static asset serving (
handle_static/mount_static_folder_at) for optional admin UI
- keep API-only mode default
- Host-aware routing (host attribute or host controllers)
- useful for explicit internal admin host separation in single process mode
Selective/Optional Reuse (P2)
veb.authintegration
- use only if vhttpd owns full auth/session model
- for token-only admin API, custom lightweight middleware stays simpler
- Template stack
- not needed for API-first mode, optional for embedded diagnostics UI
Not Recommended
- Replacing
vslimruntime routing withvebcompile-time handlers
- breaks PHP dynamic route registration model
- removes framework-level flexibility expected by PHP users
Suggested 1.1 Execution Order
- P0.1: controller split (
data,admin,debug) - P0.2: move admin auth checks to route middleware
- P0.3: centralized
before_request+not_found - P1.1: optional static admin assets (behind config flag)
- P1.2: optional CSRF middleware for admin HTML form routes
Source Notes (from vdoc)
vebdocs: route attributes, route order, host routing,register_controller, middleware,route_use,before_request,Context.not_found,Context.takeover_connveb.sse:start_connection,SSEConnection.send_message,SSEMessageveb.request_id: middleware config and generator/conditional hooksveb.csrf: route/global middleware usage andCsrfConfigveb.auth: generic auth model with DB-backed examples