showcase_chat
showcase_chat copied to clipboard
Question regarding handler
Hi!
I can't seem to find an example in fresh docs regarding the handler used in routes/index.tsx:
export async function handler(
req: Request,
ctx: HandlerContext,
): Promise<Response> {
....
}
What type of handler is this? Handlers explained in the docs (data fetching, API, middleware) look a bit different.
Thanks in advance!
With best regards, Arthur
The documentation mentions at https://fresh.deno.dev/docs/getting-started/custom-handlers
To define a handler in a route module, one must export it as a named export with the name handler. Handlers can have two forms: a plain function (catchall for all HTTP methods) or a plain object where each property is a function named by the HTTP method it handles.