Ende.ServeHandler

type alias

type Ende.ServeHandler<Addr extends Ende.Addr = Ende.Addr> = (request: Request, info: ServeHandlerInfo<Addr>) => Response | Promise<Response>

A handler for HTTP requests. Consumes a request and returns a response.

The request argument is a standard Web platform Request, and the handler must return a standard Web platform Response (or a promise resolving to one). These are the same Request and Response classes available as globals in Ende and in browsers, so the body, headers, URL, and method can all be read from the incoming Request.

If a handler throws, the server calling the handler will assume the impact of the error is isolated to the individual request. It will catch the error and if necessary will close the underlying connection.