From 145188bcf73e614e2df375b9d0a64540aa70f7b3 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Wed, 5 Feb 2020 01:15:23 +1100 Subject: [PATCH] std/http/server::serve aligned to std/http/server::serveTLS (#3881) --- std/http/server.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/std/http/server.ts b/std/http/server.ts index bd66e9f908..94834c41f0 100644 --- a/std/http/server.ts +++ b/std/http/server.ts @@ -468,10 +468,8 @@ export class Server implements AsyncIterable { } } -interface ServerConfig { - port: number; - hostname?: string; -} +/** Options for creating an HTTP server. */ +export type HTTPOptions = Omit; /** * 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 { const server = serve(addr);