1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

doc(http/server): Add coherence to the docs (#4372)

Functions that returns a server are now documented with "Create",
and functions that launches one are documented with "Start".

Also added documentation for listenAndServe that respects these
changes.

Fixes #4367
This commit is contained in:
Lucas De Angelis 2020-03-14 15:17:44 +01:00 committed by GitHub
parent ba687125e7
commit cd293f7907
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -224,7 +224,7 @@ export class Server implements AsyncIterable<ServerRequest> {
export type HTTPOptions = Omit<Deno.ListenOptions, "transport">;
/**
* Start a HTTP server
* Create a HTTP server
*
* import { serve } from "https://deno.land/std/http/server.ts";
* const body = "Hello World\n";
@ -243,6 +243,18 @@ export function serve(addr: string | HTTPOptions): Server {
return new Server(listener);
}
/**
* Start an HTTP server with given options and request handler
*
* const body = "Hello World\n";
* const options = { port: 8000 };
* listenAndServeTLS(options, (req) => {
* req.respond({ body });
* });
*
* @param options Server configuration
* @param handler Request handler
*/
export async function listenAndServe(
addr: string | HTTPOptions,
handler: (req: ServerRequest) => void
@ -284,7 +296,7 @@ export function serveTLS(options: HTTPSOptions): Server {
}
/**
* Create an HTTPS server with given options and request handler
* Start an HTTPS server with given options and request handler
*
* const body = "Hello HTTPS";
* const options = {