Search code examples
kongkong-plugin

Configure Kong plugin to only trigger for one or more methods?


Is there any way to configure a plugin to trigger only for a given method or set of methods?

-routes: 
  - name: some-route
  - paths:
      - /some-path
      plugins:
        - name: some-plugin
          methods: GET # Only run plugin for GET
          configuration:
            some-config:
            - foo
          

Solution

  • You should put the method on the route level

    -routes: 
      - name: some-route
        methods:
          - GET # Only run plugin for GET
        paths:
          - /some-path
        plugins:
          - name: some-plugin
              
              configuration:
                some-config:
                - foo