response.js 432 B

123456789101112131415161718192021
  1. /**
  2. * Send XML response
  3. * @param ctx
  4. * @param content
  5. * @returns
  6. */
  7. export const withXMLResponse = (ctx, content) => {
  8. if (ctx?.res) {
  9. const { res } = ctx;
  10. // Set header
  11. res.setHeader('Content-Type', 'text/xml');
  12. // Write the sitemap context to resonse
  13. res.write(content);
  14. // End response
  15. res.end();
  16. }
  17. // Empty props
  18. return {
  19. props: {},
  20. };
  21. };