Added auth and request storage

This commit is contained in:
2026-08-31 12:28:18 +00:00
parent 6febaf327a
commit 1ca9648c09
21 changed files with 634 additions and 117 deletions
+13 -2
View File
@@ -1,7 +1,10 @@
import type { RouteSendOptions, RouteStream } from '../routes/types.ts';
import type { RequestHeaders, RouteSendOptions, RouteStream } from '../routes/types.ts';
import type { BaseStream } from './stream/base-stream.ts';
import { HTTP_STATUS_CODE_NO_CONTENT, HTTP_STATUS_CODE_SUCCESS } from '../constants.ts';
/** Shared immutable value used when a request supplies no headers. */
const EMPTY_REQUEST_HEADERS: RequestHeaders = Object.freeze({});
/**
* Binds one application request to a connection-level stream.
*
@@ -10,16 +13,24 @@ import { HTTP_STATUS_CODE_NO_CONTENT, HTTP_STATUS_CODE_SUCCESS } from '../consta
* connection-level services such as the broadcaster.
*/
export class ApplicationRouteStream implements RouteStream {
readonly headers: RequestHeaders;
/**
* @param connection - Shared transport stream backing this request.
* @param body - Transport-decoded application payload for the route handler.
* @param path - Canonical application route selected for this request.
* @param requestId - Optional correlation ID for multiplexed transports.
* @param headers - Transport-normalized request headers for this dispatch.
*/
constructor(
readonly connection: BaseStream,
readonly body: unknown,
readonly path: string,
private readonly requestId?: string,
) {}
headers: RequestHeaders = EMPTY_REQUEST_HEADERS,
) {
this.headers = headers === EMPTY_REQUEST_HEADERS ? headers : Object.freeze({ ...headers });
}
/** Whether the underlying connection can deliver server-pushed events. */
get streaming(): boolean {