fix: error handling in fs routes (#2474)
Ran into an issue where we weren't responding with the correct status code and passed response headers. This was a bit of a rabbit hole and it was caused by us wrapping to more error handling middlewares than necessary.
This commit is contained in:
@@ -470,3 +470,19 @@ Deno.test("FreshApp - sets error on context", async () => {
|
||||
expect(thrown[0][0]).toEqual(thrown[0][1]);
|
||||
expect(thrown[1][0]).toEqual(thrown[1][1]);
|
||||
});
|
||||
|
||||
Deno.test("FreshApp - support setting request init in ctx.render()", async () => {
|
||||
const app = new App<{ text: string }>()
|
||||
.get("/", (ctx) => {
|
||||
return ctx.render(<div>ok</div>, {
|
||||
status: 416,
|
||||
headers: { "X-Foo": "foo" },
|
||||
});
|
||||
});
|
||||
|
||||
const server = new FakeServer(await app.handler());
|
||||
const res = await server.get("/");
|
||||
await res.body?.cancel();
|
||||
expect(res.status).toEqual(416);
|
||||
expect(res.headers.get("X-Foo")).toEqual("foo");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user