No9 / harmon

middleware for node-http-proxy to modify the remote website response with trumpet
Other
424 stars 62 forks source link

how to use harmon on specify url #29

Open epubreader opened 9 years ago

epubreader commented 9 years ago

I want to only use harmon to replace something on homepage, how to specify the url?

No9 commented 9 years ago

Hi @eimhee Rather than passing the harmon middleware straight as in https://github.com/No9/harmon/blob/master/examples/doge.js#L54 You will probably have to wrap it with your own middleware that applies your rules before passing it to harmon. You can look at harmon code it's self to see how the middleware pattern works. The key piece is that you make a module that returns a function that takes (req, res, next) https://github.com/No9/harmon/blob/master/index.js#L120