Overview

Last updated: 3 minutes read.

This page provides an overview on how to register one or more custom plugins to be executed at different stages or hooks in the API request/response lifecycle. If you wish to learn how to register custom plugins to be executed on the traffic logs generated by the Gateway please refer to the analytics plugins page.

If you need fine-grained control at the endpoint level then it is also possible to configure per-endpoint plugins. These are custom Golang plugins that are triggered at the end of the request processing chain before API-level Post plugins are executed.


Introduction

There are three locations where Tyk Gateway can find plugin functions:

  1. gRPC plugins: Plugin functions are implemented by a gRPC server with the associated configuration specified with the API definition. For further details on how to configure gRPC plugins, please refer to our gRPC documentation.
  2. Local plugins: Plugins are implemented by functions within source code files located on the Gateway’s file system. The API Definition allows the source code file path and function name to be configured for each plugin. For further details read on.
  3. Plugin bundles: The plugin source code and configuration are bundled into a zip file that is served by a remote web server. For further details see the plugin bundles page.

Plugin configuration

Each plugin for an API can be configured within the API Definition with the following details:

Property Description
Enabled When true, the plugin is activated
Name A name used to identify the plugin
Path The path to the source code file on the Tyk Gateway file system
Function name The name of the function that implements the plugin. The function should exist within the source code file referenced in path
Raw body only When set to true, this flag indicates that only the raw request body should be processed
Require session state When set to true, Tyk Gateway will serialize the request session state and pass it as an argument to the function that implements the plugin in the target language. This is applicable to Post, Response, and Authentication hooks only

Language configuration

For local and bundle plugins a plugin driver is configured to specify the plugin implementation language. If using gRPC plugins a grpc plugin driver should be used to instruct Tyk to request execution of plugins from within a gRPC server that is external to the Tyk process. This offers additional language support since Tyk can integrate with a gRPC server that is implemented using any supported gRPC language.

For a given API it is not possible to mix the implementation language for the plugin types: Pre, Authentication, Post, Post Authentication and Response plugins. For example, it is not possible to implement a pre request plugin in Go and also implement a post request plugin in Python for the same API.


Next steps

If you’re using the newer Tyk OAS APIs, then check out the configuring plugins for Tyk OAS APis page for further details.

If you’re using the legacy Tyk Classic APIs, then check out the configuring plugins for Tyk Classic APIs page for further details.