(filepath, res)
| 455 | } |
| 456 | |
| 457 | renderFile(filepath, res) { |
| 458 | let contents = fs.readFileSync(filepath); |
| 459 | let contentType = this.getFileContentType(filepath, res); |
| 460 | |
| 461 | for(const [key, value] of Object.entries(this.options.headers)){ |
| 462 | res.setHeader(key, value); |
| 463 | } |
| 464 | |
| 465 | if (!contentType) { |
| 466 | return res.end(contents); |
| 467 | } |
| 468 | |
| 469 | res.setHeader("Content-Type", contentType); |
| 470 | |
| 471 | if (contentType.startsWith("text/html")) { |
| 472 | // the string is important here, wrapResponse expects strings internally for HTML content (for now) |
| 473 | return res.end(contents.toString()); |
| 474 | } |
| 475 | |
| 476 | return res.end(contents); |
| 477 | } |
| 478 | |
| 479 | async eleventyDevServerMiddleware(req, res, next) { |
| 480 | if(this.#serverState === "CLOSING") { |
no test coverage detected