MCPcopy Index your code
hub / github.com/11ty/dev-server / renderFile

Method renderFile

server.js:457–477  ·  view source on GitHub ↗
(filepath, res)

Source from the content-addressed store, hash-verified

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") {

Callers 1

Calls 1

getFileContentTypeMethod · 0.95

Tested by

no test coverage detected