mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
feat: stabilize Deno.serveHttp() (#11544)
This commit moves "Deno.serveHttp()" and related types to stable namespace.
This commit is contained in:
parent
f87aa44d94
commit
3a2e94492b
6 changed files with 30 additions and 35 deletions
|
@ -203,7 +203,6 @@ fn deno_http_native(deno_exe: &str) -> Result<HttpBenchmarkResult> {
|
|||
"run",
|
||||
"--allow-net",
|
||||
"--reload",
|
||||
"--unstable",
|
||||
"cli/bench/deno_http_native.js",
|
||||
&server_addr(port),
|
||||
],
|
||||
|
|
|
@ -25,7 +25,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
|
|||
"EmitOptions",
|
||||
"EmitResult",
|
||||
"HttpClient",
|
||||
"HttpConn",
|
||||
"LinuxSignal",
|
||||
"Location",
|
||||
"MXRecord",
|
||||
|
@ -33,7 +32,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
|
|||
"Metrics",
|
||||
"OpMetrics",
|
||||
"RecordType",
|
||||
"RequestEvent",
|
||||
"ResolveDnsOptions",
|
||||
"SRVRecord",
|
||||
"SetRawOptions",
|
||||
|
@ -60,7 +58,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
|
|||
"osRelease",
|
||||
"ppid",
|
||||
"resolveDns",
|
||||
"serveHttp",
|
||||
"setRaw",
|
||||
"shutdown",
|
||||
"signal",
|
||||
|
|
29
cli/dts/lib.deno.ns.d.ts
vendored
29
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -2414,4 +2414,33 @@ declare namespace Deno {
|
|||
* ```
|
||||
*/
|
||||
export function fstat(rid: number): Promise<FileInfo>;
|
||||
|
||||
export interface RequestEvent {
|
||||
readonly request: Request;
|
||||
respondWith(r: Response | Promise<Response>): Promise<void>;
|
||||
}
|
||||
|
||||
export interface HttpConn extends AsyncIterable<RequestEvent> {
|
||||
readonly rid: number;
|
||||
|
||||
nextRequest(): Promise<RequestEvent | null>;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Services HTTP requests given a TCP or TLS socket.
|
||||
*
|
||||
* ```ts
|
||||
* const conn = await Deno.connect({ port: 80, hostname: "127.0.0.1" });
|
||||
* const httpConn = Deno.serveHttp(conn);
|
||||
* const e = await httpConn.nextRequest();
|
||||
* if (e) {
|
||||
* e.respondWith(new Response("Hello World"));
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* If `httpConn.nextRequest()` encounters an error or returns `null`
|
||||
* then the underlying HttpConn resource is closed automatically.
|
||||
*/
|
||||
export function serveHttp(conn: Conn): HttpConn;
|
||||
}
|
||||
|
|
18
cli/dts/lib.deno.unstable.d.ts
vendored
18
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -1076,24 +1076,6 @@ declare namespace Deno {
|
|||
write?: "inherit" | boolean | Array<string | URL>;
|
||||
};
|
||||
}
|
||||
|
||||
/** **UNSTABLE**: new API, yet to be vetted.
|
||||
*
|
||||
* Services HTTP requests given a TCP or TLS socket.
|
||||
*
|
||||
* ```ts
|
||||
* const conn = await Deno.connect({ port: 80, hostname: "127.0.0.1" });
|
||||
* const httpConn = Deno.serveHttp(conn);
|
||||
* const e = await httpConn.nextRequest();
|
||||
* if (e) {
|
||||
* e.respondWith(new Response("Hello World"));
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* If `httpConn.nextRequest()` encounters an error or returns `null`
|
||||
* then the underlying HttpConn resource is closed automatically.
|
||||
*/
|
||||
export function serveHttp(conn: Conn): HttpConn;
|
||||
}
|
||||
|
||||
declare function fetch(
|
||||
|
|
12
extensions/http/lib.deno_http.unstable.d.ts
vendored
12
extensions/http/lib.deno_http.unstable.d.ts
vendored
|
@ -4,18 +4,6 @@
|
|||
/// <reference lib="esnext" />
|
||||
|
||||
declare namespace Deno {
|
||||
export interface RequestEvent {
|
||||
readonly request: Request;
|
||||
respondWith(r: Response | Promise<Response>): Promise<void>;
|
||||
}
|
||||
|
||||
export interface HttpConn extends AsyncIterable<RequestEvent> {
|
||||
readonly rid: number;
|
||||
|
||||
nextRequest(): Promise<RequestEvent | null>;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
export interface WebSocketUpgrade {
|
||||
response: Response;
|
||||
socket: WebSocket;
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
permissions: __bootstrap.permissions.permissions,
|
||||
Permissions: __bootstrap.permissions.Permissions,
|
||||
PermissionStatus: __bootstrap.permissions.PermissionStatus,
|
||||
serveHttp: __bootstrap.http.serveHttp,
|
||||
};
|
||||
|
||||
__bootstrap.denoNsUnstable = {
|
||||
|
@ -125,7 +126,6 @@
|
|||
listen: __bootstrap.netUnstable.listen,
|
||||
connect: __bootstrap.netUnstable.connect,
|
||||
listenDatagram: __bootstrap.netUnstable.listenDatagram,
|
||||
serveHttp: __bootstrap.http.serveHttp,
|
||||
startTls: __bootstrap.tls.startTls,
|
||||
umask: __bootstrap.fs.umask,
|
||||
upgradeWebSocket: __bootstrap.http.upgradeWebSocket,
|
||||
|
|
Loading…
Reference in a new issue