Skip to content

Commit 325f476

Browse files
feedback
1 parent 9721e98 commit 325f476

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

packages/fresh/src/context.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,20 +377,17 @@ export class Context<State> {
377377
/**
378378
* Respond with text. Sets `Content-Type: text/plain`.
379379
* ```tsx
380-
* ctx.text("Hello World!");
380+
* app.use(ctx => ctx.text("Hello World!"));
381381
* ```
382382
*/
383383
text(content: string, init?: ResponseInit): Response {
384-
const headers = getHeadersFromInit(init);
385-
headers.set("Content-Type", "text/plain; charset=utf-8");
386-
387-
return new Response(content, { ...init, headers });
384+
return new Response(content, init);
388385
}
389386

390387
/**
391388
* Respond with html string. Sets `Content-Type: text/html`.
392389
* ```tsx
393-
* ctx.html("<h1>foo</h1>");
390+
* app.get("/", ctx => ctx.html("<h1>foo</h1>"));
394391
* ```
395392
*/
396393
html(content: string, init?: ResponseInit): Response {
@@ -404,7 +401,7 @@ export class Context<State> {
404401
* Respond with json string, same as `Response.json()`. Sets
405402
* `Content-Type: application/json`.
406403
* ```tsx
407-
* ctx.json({ foo: 123 });
404+
* app.get("/", ctx => ctx.json({ foo: 123 }));
408405
* ```
409406
*/
410407
// deno-lint-ignore no-explicit-any

packages/fresh/src/context_test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Deno.test("ctx.text()", async () => {
114114
const server = new FakeServer(app.handler());
115115
const res = await server.get("/");
116116

117-
expect(res.headers.get("Content-Type")).toEqual("text/plain; charset=utf-8");
117+
expect(res.headers.get("Content-Type")).toEqual("text/plain;charset=UTF-8");
118118
const text = await res.text();
119119
expect(text).toEqual("foobar");
120120
});

0 commit comments

Comments
 (0)