diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-02-05 01:15:23 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-04 15:15:23 +0100 |
commit | 145188bcf73e614e2df375b9d0a64540aa70f7b3 (patch) | |
tree | cf0b2af5845945ed85759653462b57bcb96a1e4b /std | |
parent | 70eccff7f1b82a726e22753716faeb4bdc1d2823 (diff) |
std/http/server::serve aligned to std/http/server::serveTLS (#3881)
Diffstat (limited to 'std')
-rw-r--r-- | std/http/server.ts | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/std/http/server.ts b/std/http/server.ts index bd66e9f90..94834c41f 100644 --- a/std/http/server.ts +++ b/std/http/server.ts @@ -468,10 +468,8 @@ export class Server implements AsyncIterable<ServerRequest> { } } -interface ServerConfig { - port: number; - hostname?: string; -} +/** Options for creating an HTTP server. */ +export type HTTPOptions = Omit<Deno.ListenOptions, "transport">; /** * Start a HTTP server @@ -483,7 +481,7 @@ interface ServerConfig { * req.respond({ body }); * } */ -export function serve(addr: string | ServerConfig): Server { +export function serve(addr: string | HTTPOptions): Server { if (typeof addr === "string") { const [hostname, port] = addr.split(":"); addr = { hostname, port: Number(port) }; @@ -494,7 +492,7 @@ export function serve(addr: string | ServerConfig): Server { } export async function listenAndServe( - addr: string | ServerConfig, + addr: string | HTTPOptions, handler: (req: ServerRequest) => void ): Promise<void> { const server = serve(addr); |