Execution Order of Custom Plugins

Hi Team.
I’m currently deep-diving into tyk golang custom plugins
Now, I have a question about custom plugins and body transform

1) Execution order of custom plugins after upstream url response returned.

I found that there’s 5 types of custom plugins and following is the execution order
pre → auth_check → post_auth_check → post → response

There’s more detailed execution order before post custom plugins.
https://tyk.io/docs/concepts/middleware-execution-order/

But I couldn’t find the execution order after upstream url response returned.

could you share more detailed execution order and let me know execution order between body transform(response body) and response custom plugins?

Can I execute response plugin before body transform? Because in my case, there’s gzip data will be returned from upstream service, so i want to decompress before body transform. if there’s an another option, please let me know.

2) Can I add more than 1 body transformation and custom plugins?

Regarding custom plugins, it seems array type is configured, so i can add more than 1 custom plugins. Is it possible to do like below. If so, How will it work (especially execution order) ?

 "custom_middleware": {
      "pre": [
        {
          "name": "Test",
          "path": "/plugin-source/plugin_v4.3.1_linux_amd64.so",
          "require_session": false,
          "raw_body_only": false
        },
       {
          "name": "Test2",
          "path": "/plugin-source/plugin_v4.3.1_linux_amd64.so",
          "require_session": false,
          "raw_body_only": false
        }
      ],
      "post": [],
      "post_key_auth": [],
      "auth_check": {
        "name": "",
        "path": "",
        "require_session": false,
        "raw_body_only": false
      },
      "response": [],
      "driver": "goplugin",
      "id_extractor": {
        "extract_from": "",
        "extract_with": "",
        "extractor_config": {}
      }
    },

Also About Body Transform for response body, can i add more than 1 ?
https://tyk.io/docs/advanced-configuration/transform-traffic/response-body/

Thanks for your help in advance.

Hi @ghgh,

1) Execution order of custom plugins after upstream url response returned.

I’ll need to do some investigation regarding the execution order after the upstream response is returned. Although for your scenario, you don’t need to write a response plugin to handle compression before applying body transform. Our transform middleware already handles compressed data. If the upstream response is compressed, it would decompress, apply transform, recompress and pass it on to the next in the chain. You can take a peek here.

2) Can I add more than 1 body transformation and custom plugins?

Test would be executed before Test2. Array is an ordered data structure, so this is expected.
As an extra note, you might have noticed auth_check middleware is object type. So this can only be one middleware.
Yes, you can also add more than 1 body transform, it’s an array type as well. In this case though, the order is not important, it’s more of the Path and Method configured for each. A particular transform is only executed when the path and method of a request match what you’ve configured.

Hope this helps.

1 Like

Thanks for your reply
It is really helpful and I got a lot out of it.

If you get anything or documents about the execution order after upstream response returned,
please let me know.