mitmproxy/examples/addons/commands-flows.py
Maximilian Hils 08895e9ba6 restructure examples
- restructure examples (fix #4031)
 - remove example dependencies from setup.py,
   we do not need special dependencies for our supported addons.
 - unify how we generate docs from code
 - improve example docs
2020-06-23 16:00:14 +02:00

20 lines
401 B
Python

"""Handle flows as command arguments."""
import typing
from mitmproxy import command
from mitmproxy import ctx
from mitmproxy import flow
class MyAddon:
@command.command("myaddon.addheader")
def addheader(self, flows: typing.Sequence[flow.Flow]) -> None:
for f in flows:
f.request.headers["myheader"] = "value"
ctx.log.alert("done")
addons = [
MyAddon()
]