API change: Deno.startHttp -> Deno.serveHttp (#10087)

This commit is contained in:
Ryan Dahl 2021-04-09 11:54:27 -04:00 committed by GitHub
parent cd0560210a
commit c6e7a243d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 18 deletions

View file

@ -1211,18 +1211,20 @@ declare namespace Deno {
/** **UNSTABLE**: new API, yet to be vetted.
*
* Parse HTTP requests from the given connection
* Services HTTP requests given a TCP or TLS socket.
*
* ```ts
* const httpConn = await Deno.startHttp(conn);
* const { request, respondWith } = await httpConn.next();
* respondWith(new Response("Hello World"));
* const httpConn = Deno.serveHttp(conn);
* const e = await httpConn.nextRequest();
* if (e) {
* e.respondWith(new Response("Hello World"));
* }
* ```
*
* If `httpConn.next()` encounters an error or returns `done == true` then
* the underlying HttpConn resource is closed automatically.
* If `httpConn.nextRequest()` encounters an error or returns `null`
* then the underlying HttpConn resource is closed automatically.
*/
export function startHttp(conn: Conn): HttpConn;
export function serveHttp(conn: Conn): HttpConn;
}
declare function fetch(