Integration
vow-examples/vow-web-server/integration_rest/ demonstrates wiring vow-web-server with Tier-1 companion packages via path deps — the pattern used before publishing everything to vpm.
Layout
Section titled “Layout”vow-examples/vow-web-server/integration_rest/├── project.toml # path deps to framework + vow-libs├── src/main.vow # REST API with middleware stack└── e2e.sh # build + dep tests (no live listen)Dependencies
Section titled “Dependencies”[deps]vow-web-server = { path = "../../../vow-frameworks/vow-web-server" }vow-body-parser = { path = "../../../vow-libs/vow-body-parser" }vow-cors = { path = "../../../vow-libs/vow-cors" }vow-log = { path = "../../../vow-libs/vow-log" }vow-rbac = { path = "../../../vow-libs/vow-rbac" }vow-postgres = { path = "../../../vow-libs/vow-postgres" }Middleware stack
Section titled “Middleware stack”The app layers built-in vow-web-server middleware with package helpers:
import vws from vow_web_serverimport vbp from vow_body_parserimport vc from vow_corsimport vrb from vow_rbacimport vpg from vow_postgres
fn main(caps: Caps) -> int { let opts = vc.defaults("*"); let a = vws.use_cors_opts( vws.use_auth(vws.use_json(vws.use_log(vws.app()))), vc.allow_origin(opts), vc.allow_methods(opts), vc.allow_headers(opts), vc.cors_max_age(opts) ); let a = vws.post(vws.get(a, "/item", get_item), "/item", create_item); return match caps.net { Some(cap) => vws.listen(a, cap, 8787), None => 0 - 1, };}| Layer | Package | Role |
|---|---|---|
| Logger | vow-web-server use_log |
Request logging |
| JSON body | vow-web-server use_json |
Parse JSON into context |
| Auth header | vow-web-server use_auth |
Require Authorization |
| CORS | vow-cors | Preflight + response headers |
| RBAC | vow-rbac | Role check on X-Roles header |
| Body fallback | vow-body-parser | Parse when context empty |
| Postgres DSN | vow-postgres | DSN string in GET response (demo) |
Handlers
Section titled “Handlers”GET /item — returns stored name + postgres DSN demo string:
fn get_item(_req: request.Request) -> response.Response { let dsn = vpg.dsn("localhost", 5432, "app", "widgets"); let body = "{\"name\":\"" + store_name() + "\",\"dsn\":\"" + dsn + "\"}"; return vws.json(body);}POST /item — RBAC gate + JSON parse:
fn create_item(req: request.Request) -> response.Response { let roles = vws.header(req, "X-Roles"); let auth = vrb.require_role(roles, "editor"); // ... parse via context_value or vbp.from_http ...}Requires X-Roles containing editor and a valid JSON body.
Run locally
Section titled “Run locally”cd vow-examples/vow-web-server/integration_restvpm install./e2e.sh# Full server:vow run src/main.vow -- --grant net:Manual curl (with auth + role):
curl -sf http://127.0.0.1:8787/item
curl -X POST http://127.0.0.1:8787/item \ -H 'Authorization: Bearer token' \ -H 'X-Roles: editor' \ -H 'Content-Type: application/json' \ -d '{"name":"widget"}'What this proves
Section titled “What this proves”- Packaged imports (
import vws from vow_web_server) work alongside path deps - Built-in middleware composes with external packages
- Handler-level RBAC and body parsing without custom fn middleware
- End-to-end build chain for gallery / CI smoke