Skip to content

Move Handler into base-http as the shared request interface, called with a server or client context. - #80

Merged
ioquatix merged 2 commits into
mainfrom
shared-request-interface
Nov 20, 2026
Merged

ioquatix merged 2 commits into
mainfrom
shared-request-interface

Conversation

@ioquatix

Copy link
Copy Markdown
Contributor

Move the server's Handler into base-http as Handler<'scope, C: HandlerContext>, called as call(request, &mut context, &cancellation), which base-http-server re-exports, as design/middleware.md decides, with HandlerContext giving middleware generic over the context the exchange's interim hook. Servers pass a ServerContext, which carries the connection's new Peer (peer and local addresses, whether the connection is encrypted and its negotiated application protocol, and early data, always false until HTTP/3) and an InterimSender: instead of borrowing the connection's writer, which would make a handler's response type depend on that borrow, the sender hands each interim response to the connection's InterimRelay, and the server writes it while it continues to poll the handler, so the context has no type or lifetime parameter and a send allocates nothing. Applications calling a client pass a ClientContext<I> with their observer and RequestOptions, which has no options yet; the client implements the interface in the next change. call_send moves to base-http. The server's entry points, and the fixtures' scheduler alias, now require SocketPeerAddress and SocketLocalAddress, which every Base backend provides; the fixtures' ServerContext and ClientContext become ServerFixture and ClientFixture. Tests cover a middleware generic over the context wrapping a server handler and a client handler alike, layers applying in order, a layer answering without its delegate, a narrower cancellation, a borrowed body passing through without copying, interim responses through either context, a server middleware reading the Peer, a compile-fail test placing a server-only middleware on the client side, Peer over plain TCP and TLS, the relay itself, and a handler returning while its interim response is being written; region coverage is complete, and the suite passes on Rust 1.92 and 1.99. The TLS server name is not reported yet, because base-endpoint 0.3 does not expose it.

@ioquatix
ioquatix merged commit cb58054 into main Nov 20, 2026
8 checks passed
@ioquatix
ioquatix deleted the shared-request-interface branch November 20, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant