Add auth controls and headers
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user