--- id: server-adapter name: HttpAdapter — ProtocolHandler with hyper over BiStream status: completed depends_on: [server-core-types, server-auth, server-healthz-decoy] scope: moderate risk: medium impact: component level: implementation tags: [server, phase-1] --- ## Description Port the `HttpAdapter` (`ProtocolHandler` for `http/1.1` + `h2`) from `/workspace/@alkdev/alknet/crates/alknet-http/src/server/adapter.rs`, adapted to alkcall's shapes: `handle()` receives a `Connection` (alkcall::core::types), takes the `BiStream` from `accept_bi()`, wraps with `TokioIo`, drives hyper's http1/http2 connection builder against the axum `Router` (built once at construction, `with_decoy` / `with_extra_routes` builders per ADR-046). Branch on `connection.remote_alpn()`. Leave a route slot for the WS upgrade (wired in the websocket tasks). ## Acceptance Criteria - [x] `HttpAdapter::new/h2/for_alpn` + `with_decoy` + `with_extra_routes` ported - [x] `ProtocolHandler` impl drives hyper over the BiStream; returns on connection close - [x] Router merges extra routes; default surface wins collisions - [x] Integration test: full HTTP request/response cycle over `tokio::io::DuplexStream` → `Connection::from_bidi` → adapter - [x] `cargo test` passes; feature gates `h2`/`http1` both compile ## References - docs/architecture/http-server.md (§Running axum over a bidirectional stream) - docs/architecture/decisions/002-protocol-handler-trait.md - alkcall: `core::types::Connection::accept_bi` returns joined `BiStream` (alkcall ADR-005) ## Notes > Agent fills during implementation. ## Summary Ported `src/server/adapter.rs`: HttpAdapter (ProtocolHandler for h2/http1.1), accept_bi→BiStream→TokioIo→hyper auto builder with h2 connect-protocol enabled, with_decoy/with_extra_routes builders, RESERVED_PATHS + WS_UPGRADE_PATH constants (WS handler wired in the websocket task). Integration tests: full request/response cycle, healthz, decoy 404 — all over tokio DuplexStream → Connection::from_bidi → ProtocolHandler::handle.