Files
sweet/tests/fixture/routes/intercept_args.tsx
T
Luca Casonato da340daeb2 BREAKING: move a bunch of types into server/ (#263)
Moved some server only types like `RouteConfig` into server/. They were
previously in runtime/.
2022-06-21 15:21:07 +02:00

27 lines
582 B
TypeScript

/** @jsx h */
import { h } from "preact";
import { Handlers, PageProps } from "$fresh/server.ts";
interface Data extends Record<string, unknown> {
info: string;
}
export default function Page({ data }: PageProps<Data>) {
return <div>{data.info}</div>;
}
export const handler: Handlers<Data> = {
GET(req, { render }) {
if (req.headers.get("accept")?.includes("text/html")) {
return render({
info: "intercepted",
});
} else {
return new Response("This is plain text");
}
},
POST() {
return new Response("POST response");
},
};