aboutsummaryrefslogtreecommitdiffstats
path: root/examples/addons/commands-flows.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/addons/commands-flows.py')
-rw-r--r--examples/addons/commands-flows.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/addons/commands-flows.py b/examples/addons/commands-flows.py
new file mode 100644
index 00000000..cebc8f9d
--- /dev/null
+++ b/examples/addons/commands-flows.py
@@ -0,0 +1,21 @@
+import typing
+
+from mitmproxy import command
+from mitmproxy import ctx
+from mitmproxy import flow
+
+
+class MyAddon:
+ def __init__(self):
+ self.num = 0
+
+ @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()
+]