Questions & Answers

Can I customize the content type of the responses?

Deepkit HTTP
50 up-votes
Warning: The answer is generated by an artificial intelligence. It might not be correct.
To adjust rating, open the thread in Discord and click on the up/down vote button.

Yes, you can customize the content type of the responses. You can do this by creating a Response object with the desired content type and returning it from your route handler.

Here's an example:

import { Response } from '@deepkit/http';

router.get('/', () => {
  const content = '<h1>Hello World</h1>';
  return new Response(content, 'text/plain');
});

In this example, the response will have a Content-Type header of text/plain instead of the default text/html.