Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a refactor of the Admin API to allow for a more RESTful experience (#98) and an easier and more flexible way to create plugins that have API endpoints.
before
andon_error
callbacks.POST
,PUT
,PATCH
endpoints supportx-ww-application-form-encoded
as well asapplication/json
.keyauth_credentials
andbasicauth_credentials
byconsumer_id
.Globally: less abstraction, less god-class pattern for more flexibility. Creating this kind of API is not that easy with Lapis but this is still a good shot I think, and can still be improved later.
New routes
This is a list of all the routes currently supported (trailing slash doesn't matter):
And the current plugins with an API are moved to:
Changes to the documentation
The documentation should reflect the new routes changes, the content types support, and something very nice is now the ability to remove the "Retrieve the id of the created API/Consumer..." etc. Now we can simply pass the
name
of an API:becomes:
(key_names is
apikey
by default since #253).How to extend the API
If for the core, add a file in
kong/plugins/api/routes
. If for a plugin, it should be added in the plugin's directory, namedapi.lua
.Template:
You get one
before
andon_error
function for each endpoint.on_error
is implemented by default, allowing the developer to yield errors (especially DAO errors) like this:A bonus are the
crud_helpers
, since otherwise a lot of code would be duplicated. They are just helpers that are not necessary, one could implement some endpoints without them, as they simply wrap calls to the DAO and the error handling.Feedback/tests are welcomed before merging this, I will maybe polish it but at least it's opening the discussion.