Skip to content

Commit

Permalink
feat(admin) add plugins to /consumers endpoint (Kong#2714)
Browse files Browse the repository at this point in the history
  • Loading branch information
kikito authored Jul 26, 2017
1 parent e1cec5b commit 66cb4b5
Show file tree
Hide file tree
Showing 3 changed files with 521 additions and 3 deletions.
45 changes: 44 additions & 1 deletion kong/api/routes/consumers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,48 @@ return {
DELETE = function(self, dao_factory)
crud.delete(self.consumer, dao_factory.consumers)
end
}
},

["/consumers/:username_or_id/plugins/"] = {
before = function(self, dao_factory, helpers)
self.params.username_or_id = ngx.unescape_uri(self.params.username_or_id)
crud.find_consumer_by_username_or_id(self, dao_factory, helpers)
self.params.consumer_id = self.consumer.id
end,

GET = function(self, dao_factory)
crud.paginated_set(self, dao_factory.plugins)
end,

POST = function(self, dao_factory)
crud.post(self.params, dao_factory.plugins)
end,

PUT = function(self, dao_factory)
crud.put(self.params, dao_factory.plugins)
end
},

["/consumers/:username_or_id/plugins/:id"] = {
before = function(self, dao_factory, helpers)
self.params.username_or_id = ngx.unescape_uri(self.params.username_or_id)
crud.find_consumer_by_username_or_id(self, dao_factory, helpers)
crud.find_plugin_by_filter(self, dao_factory, {
consumer_id = self.consumer.id,
id = self.params.id,
}, helpers)
end,

GET = function(self, dao_factory, helpers)
return helpers.responses.send_HTTP_OK(self.plugin)
end,

PATCH = function(self, dao_factory)
crud.patch(self.params, dao_factory.plugins, self.plugin)
end,

DELETE = function(self, dao_factory)
crud.delete(self.plugin, dao_factory.plugins)
end
},
}
Loading

0 comments on commit 66cb4b5

Please sign in to comment.