Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
function serveListener
Deprecated
Deprecated

(will be removed after 1.0.0) Use Deno.serve instead.

import { serveListener } from "https://deno.land/x/fathym_eac_runtime@v0.0.140/src/src.deps.ts";

Constructs a server, accepts incoming connections on the given listener, and handles requests on these connections with the given handler.

import { serveListener } from "https://deno.land/std@0.224.0/http/server.ts";

const listener = Deno.listen({ port: 4505 });

console.log("server listening on http://localhost:4505");

await serveListener(listener, (request) => {
  const body = `Your user-agent is:\n\n${request.headers.get(
    "user-agent",
  ) ?? "Unknown"}`;

  return new Response(body, { status: 200 });
});

Parameters

listener: Deno.Listener

The listener to accept connections from.

handler: Handler

The handler for individual HTTP requests.

optional
options: ServeListenerOptions

Optional serve options.

Returns

Promise<void>