As you can see in the Introspect section, there are two types of capture mode in Zoraxy plugin API.
Notes: When this document mention the term “endpoint”, it means a particular sub-path on the plugin side. For example /capture or /sniff . In actual implementation, this can be a http.HandleFunc or http.Handle depends on the plugin implementation.
Static Capture Mode register a static path to Zoraxy, when the plugin is enabled on a certain HTTP proxy rule, all request that matches the static capture registered paths are forwarded to the plugin without asking first. The overall process is shown in the diagram below.
The main benefit of static capture mode is that the capture paths are stored in radix tree. That means it takes O(logn) time to resolve the path and forward the request. Hence, this mode is generally faster if your plugin always listens to a few certain paths for extended functionalities.
Dynamic Capture Mode register two endpoints to Zoraxy.
The whole process will takes a few request exchange between plugin and Zoraxy core. Since both of them are communicating via the loopback interface, speed should not be too big of a concern here.
The request handling flow is shown in the diagram below.
Once Zoraxy receive a request from a client that matches one of the HTTP Proxy Rule, Zoraxy will forward the request header to all the plugins that matches the following criteria
Then the plugin /sniff endpoint will receive some basic header information about the request, and response with SniffResultAccpet or SniffResultSkip to accept or reject handling such request. The response are defined in zoraxy_plugin as a public type where you can access with zoraxy_plugin.SniffresultAccept and zoraxy_plugin.SniffResultSkip respectively.
Note that this shall only be used if static capture mode cannot satisfy your needs in implementation the feature you want, as dynamic capture is way slower than static capture mode .
It is possible for you to mix both Static and Capture modes if that is what you want. A few thing you need to know about mixing both mode in single plugin