diff options
author | Lucas De Angelis <lucas.de-angelis@epitech.eu> | 2020-03-14 15:17:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-14 10:17:44 -0400 |
commit | cd293f7907c831f31d6ec23d83454d6212e5fda4 (patch) | |
tree | c91234de312b2b493df7349bcdc94bf7ac3eec7b | |
parent | ba687125e7ce5574811aebdcb7eac6b4194e6def (diff) |
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
-rw-r--r-- | std/http/server.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/std/http/server.ts b/std/http/server.ts index d7ed60c53..34b17cc26 100644 --- a/std/http/server.ts +++ b/std/http/server.ts @@ -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 = { |