This allows users to control the `preact` version independently of fresh itself.
21 lines
456 B
TypeScript
21 lines
456 B
TypeScript
/** @jsx h */
|
|
import { h } from "preact";
|
|
import { HandlerContext } from "$fresh/server.ts";
|
|
|
|
export default function Page() {
|
|
return <div>This is HTML</div>;
|
|
}
|
|
|
|
export const handler = {
|
|
GET(req: Request, { render }: HandlerContext) {
|
|
if (req.headers.get("accept")?.includes("text/html")) {
|
|
return render();
|
|
} else {
|
|
return new Response("This is plain text");
|
|
}
|
|
},
|
|
POST() {
|
|
return new Response("POST response");
|
|
},
|
|
};
|