This commit merges API routes and pages into a single concept. The pages/api folder is now not special anymore.
22 lines
455 B
TypeScript
22 lines
455 B
TypeScript
/** @jsx h */
|
|
|
|
import { h } from "../deps.ts";
|
|
import { HandlerContext } from "../../../server.ts";
|
|
|
|
export default function Page() {
|
|
return <div>This is HTML</div>;
|
|
}
|
|
|
|
export const handler = {
|
|
GET({ req, 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");
|
|
},
|
|
};
|