# Prioritize the Kong Plugins for each service

**URL:** <https://discuss.konghq.com/t/prioritize-the-kong-plugins-for-each-service/3115>\
**Category:** Questions\
**Created:** [March 27, 2019, 5:55am UTC](https://discuss.konghq.com/t/prioritize-the-kong-plugins-for-each-service/3115 "2019-03-27T05:55:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![subrat](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@subrat](https://discuss.konghq.com/u/subrat)\
**Post date:** [March 27, 2019, 5:55am UTC](https://discuss.konghq.com/t/prioritize-the-kong-plugins-for-each-service/3115/1 "2019-03-27T05:55:58Z")

</div>

Hi  
As per the current order of execution for the bundled plugins, first ACL and then the request-transformer plugin will be executed if both of them I am adding to a service.  
For a service I need to customize the plugin execution, I need to execute request-transformer plugin first and then ACL.  
How can I achieve it?

---

<div class="post-metadata">

**Author:** ![kikito](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/kikito/32/15_2.png) [@kikito](https://discuss.konghq.com/u/kikito)\
**Post date:** [March 27, 2019, 4:36pm UTC](https://discuss.konghq.com/t/prioritize-the-kong-plugins-for-each-service/3115/2 "2019-03-27T16:36:16Z")

</div>

The order in which the plugins are executed depends on each plugins’ PRIORITY field, set up on its handler.lua file.

The request-transformer plugin has a priority of [801](https://github.com/Kong/kong/blob/master/kong/plugins/request-transformer/handler.lua#L15) while the ACL plugin’s is [950](https://github.com/Kong/kong/blob/master/kong/plugins/acl/handler.lua#L42), so ACL will always come first.

A possible solution would be creating a custom plugin: it would be a copy of `request-transformer` (named something else, like `request-transformer-high-priority`) which is exactly the same as `request-transformer` but with a priority higher than 950. Then use that modified plugin instead of the default `request-transformer`.

You might want to look at our [Plugin Development Guide’s Install Section](https://docs.konghq.com/1.0.x/plugin-development/distribution/) for details about how to install a custom plugin.

---

<div class="post-metadata">

**Author:** ![subrat](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@subrat](https://discuss.konghq.com/u/subrat)\
**Post date:** [March 28, 2019, 12:29pm UTC](https://discuss.konghq.com/t/prioritize-the-kong-plugins-for-each-service/3115/3 "2019-03-28T12:29:31Z")

</div>

## Hi, I have created a custom plugin same as request-transformer plugin. handler.lua

local BasePlugin = require “kong.plugins.base\_plugin”  
local access = require “kong.plugins.kong-custom-plugin.access”

local CustomPluginHandler = BasePlugin:extend()

CustomPluginHandler.PRIORITY = 952  
CustomPluginHandler.VERSION = “1.0.0”

function CustomPluginHandler:new()  
CustomPluginHandler.super.new(self, “kong-custom-plugin”)  
end

function CustomPluginHandler:access(conf)  
CustomPluginHandler.super.access(self)  
access.execute(conf)  
end

return CustomPluginHandler

And I am using the same schema.lua and access.lua files of request-transformer.

## The custom plugin created successfully and also I am able to add to a service. However, when I am trying to update the plugin all the plugin fields are displayed. I am only able to see api\_id, service\_id, route\_id and consumer\_id. I should be able to view all the field similar to request-transformer. What changes required, am I not reading the access.lua properly? Output of adding plugin:

/etc/kong # curl -i -X POST --url [http://localhost:8001/services/example-service/plugins/](http://localhost:8001/services/example-service/plugins/) --data name=kong-custom-plugin  
HTTP/1.1 201 Created  
Date: Thu, 28 Mar 2019 14:33:36 GMT  
Content-Type: application/json; charset=utf-8  
Transfer-Encoding: chunked  
Connection: keep-alive  
Access-Control-Allow-Origin: \*  
X-Kong-Admin-Request-ID: oO2xfOnJAZREEF9kRyq7BxJal2UhA7P2  
Server: kong/0.34-1-enterprise-edition

{“created\_at”:1553783616000," **config":{}** ,“id”:“a8459a53-c82e-4bf8-bdac-a9d51696782a”,“enabled”:true,“service\_id”:“d8c6891a-877b-4d22-84d0-bebc9b58150f”,“name”:“kong-custom-plugin”}

Note : config is blank
