Skip to content

Commit

Permalink
docs: add dynamic replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
bfncs authored Nov 22, 2023
1 parent 01b5791 commit ea25bc8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ app.use(serveStatic('public'));

app.listen(3000);
```
### Dynamic replacements

You might also replace dynamically with access to all the content of [Request](https://expressjs.com/de/api.html#req) and [Response](https://expressjs.com/de/api.html#res):

```
stringReplace({
'$host' => (req, res) => 'your host ' + req.hostname
});
## Configuration
Expand All @@ -61,4 +69,4 @@ app.use(stringReplace({

The default regex is `/^text\/|^application\/json$|^application\/xml$/`, which will match `text/*`, `application/json`, and `application/xml`. Any response with a Content-Type header that doesn't match the regex is ignored and passed-through without modification.

Also any response without a Content-Type header is ignored and passed-through without any modification.
Also any response without a Content-Type header is ignored and passed-through without any modification.

0 comments on commit ea25bc8

Please sign in to comment.