fix: ctx.render headers not working (#1927)
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import type { Handlers } from "$fresh/server.ts";
|
||||
|
||||
export const handler: Handlers<unknown, unknown> = {
|
||||
GET(_, ctx) {
|
||||
const headers = [["x-foo", "Hello world!"]] as [string, string][];
|
||||
return ctx.render(undefined, { headers });
|
||||
},
|
||||
};
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
Should have <code>X-Foo</code> header set.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { Handlers } from "$fresh/server.ts";
|
||||
|
||||
export const handler: Handlers<unknown, unknown> = {
|
||||
GET(_, ctx) {
|
||||
const headers = new Headers();
|
||||
headers.set("x-foo", "Hello world!");
|
||||
return ctx.render(undefined, { headers });
|
||||
},
|
||||
};
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
Should have <code>X-Foo</code> header set.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { Handlers } from "$fresh/server.ts";
|
||||
|
||||
export const handler: Handlers<unknown, unknown> = {
|
||||
GET(_, ctx) {
|
||||
const headers = {
|
||||
"x-foo": "Hello world!",
|
||||
};
|
||||
return ctx.render(undefined, { headers });
|
||||
},
|
||||
};
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
Should have <code>X-Foo</code> header set.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import * as path from "https://deno.land/std@0.192.0/path/mod.ts";
|
||||
|
||||
const __dirname = path.dirname(path.fromFileUrl(import.meta.url));
|
||||
|
||||
const links: string[] = [];
|
||||
for (const file of Deno.readDirSync(__dirname)) {
|
||||
if (file.name.startsWith("index")) continue;
|
||||
const name = path.basename(file.name, path.extname(file.name));
|
||||
links.push(name);
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
<h1>Tests</h1>
|
||||
<ul>
|
||||
{links.sort().map((link) => {
|
||||
return (
|
||||
<li key={link}>
|
||||
<a href={`/${link}`}>{link}</a>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user