diff options
-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); |