inject-body
Inject contents into the HTML <body>
tag of an HTTP response
const createServer = ;const fetch = ;const injectBody = ; ;
Installation
npm install inject-body
API
const injectBody = ;
injectBody(response, contents)
response: http.ServerResponse
contents: Buffer
If the media type of the response is text/html
, it inserts a given contents into the response body as the first child of <body>
tag, with increasing the value of Content-Length
header if necessary.
const createServer = ;const fetch = ;const injectBody = ; const html = Buffer;const inserted = Buffer; ;
If the media type is not text/html
or the response body has no <body>
tag, it does nothing.
class injectBody.InjectBody(contents)
contents: Buffer
Return: Function
Create a new injectBody
function with the fixed contents
argument. Use this class if a server will inject the same contents into every HTML response many times.
const InjectBody = ; const injectStyle = Buffer;
License
ISC License © 2018 Shinnosuke Watanabe