Injection plugin idea (inject strings, html, tmpl)

I envision the possibility to inject scripts, or parts of html etc. into the response body.

The first vision was to abuse the template directive, but this would most likely lead to horrible html and due to the maximum request_body placeholder to broken pages.

Before starting work on something like this, I would love some more thoughts.

inject [basepath] {
    ext "extensions"
    before "location to inject"
    after "location to inject"
    string "string to inject"
    file "template or html to inject"
inject / {
    ext .html .php
    before "</html>"
    after "<head>"
    string "<p>{{IP}}</p>"
    file new-navigation.tmpl

Does that make sense?

1 Like

What do you mean by this, exactly? Why is this an abuse of templates?

The use case I was suggesting was having the proxy directive and then add some banner and scripts into the answer. This seems not really how the templates should/could be used.
Especially considering, that the response needs to be in the template containing the banner and script code, but as the request_body placeholder is limited this could lead to strange behavior.

Additionally added scripts would be “injected” outside the <html> tags of the response leading to even more craziness.

Could I clarify?