feat: add status and headers overwrite for HandlerContext.render (#725)

This commit is contained in:
Leo Kettmeir
2023-05-31 10:09:53 +02:00
committed by GitHub
parent c172a70181
commit 060e2bb50d
5 changed files with 49 additions and 5 deletions
+12
View File
@@ -148,6 +148,18 @@ Deno.test("/intercept_args - GET html", async () => {
assertStringIncludes(body, "<div>intercepted</div>");
});
Deno.test("/status_overwrite", async () => {
const req = new Request("https://fresh.deno.dev/status_overwrite", {
headers: { "accept": "text/html" },
});
const resp = await router(req);
assert(resp);
assertEquals(resp.status, Status.Unauthorized);
assertEquals(resp.headers.get("x-some-header"), "foo");
const body = await resp.text();
assertStringIncludes(body, "<div>This is HTML</div>");
});
Deno.test("/api/get_only - NOTAMETHOD", async () => {
const resp = await router(
new Request("https://fresh.deno.dev/api/get_only", {