Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Admin API now supports form-encoded and json #236

Merged
merged 3 commits into from
May 18, 2015

Conversation

thibaultcha
Copy link
Member

  • Admin API accepts both form-encoded and JSON parameters. parse_params() is a custom Lapis helper which parses form-encoded or application/json parameters. If sending form-encoded, it will un-nest keys like value.object=123 to {value={object=123}}
  • Fix a bug in the schema validation. If a field had more than 1 rule, it would only validate one of them.
  • Fix Lapis's parsing behaviour with params such as ?key[1]=val being parsed as {["1"]="val"}. it is now properly parsed as {"val"}
  • Fix more bugs related with the DAO
  • Refactored a lot of code, considerably reducing LOCs
  • A lot more tests for the Admin API
  • Change current PUT to be PATCH (current PUT behaves like PATCH)
  • Implement real PUT

We can now query the Admin API with form-encoded params or a JSON body assuming the content type contains application/json. Malformed JSON will return a 400.

Most of the new LOCs are tests, otherwise the actual number of LOCs is considerably reduced.

Hold on before merging, this maybe needs a bit more testing but opening to allow discussion.

@ahmadnassri
Copy link
Contributor

We can now query the Admin API with form-encoded params or a JSON body

amazing! been waiting for this! good work! 👏

this will also make the documentation so much cleaner!

@thibaultcha thibaultcha force-pushed the feat/admin-api-content-type branch 2 times, most recently from f021278 to beb9d4e Compare May 13, 2015 23:43
- `parse_params()` is a Lapis helper which parses form-encoded or
  application/json parameters. If sending form-encoded, it will unnest
  keys like `value.object=123` to `{value={object=123}}`
- fix a bug in the schema validation. If a filed had more than 1 rule,
  it would only validate one of them.
- fix Lapis's parsing behaviour with params such as `?key[1]=val`
  being parsed as `{["1"]="val"}`. it is now properly parsed as `{"val"}`
- http_client.lua's `put()` can now send form-encoded payloads, nothing wrong with
  that

refactor: `render_list` leverages Lapis utils

fix a couple of bugs in Admin API + tests

- bonus: refactor http_client.lua for a +50% smaller file
We can know if there was an error parsing the JSON by testing for
`self.json` after the parsing happened.
@thibaultcha thibaultcha force-pushed the feat/admin-api-content-type branch from 0497eea to e9e56ea Compare May 14, 2015 21:38
@sonicaghi
Copy link
Member

@ahmadnassri @nijikokun who updates the doc?

@thibaultcha
Copy link
Member Author

We'll do it when finished and merged

@thibaultcha thibaultcha force-pushed the feat/admin-api-content-type branch from 4456850 to fbd58c2 Compare May 15, 2015 23:41
@thibaultcha
Copy link
Member Author

Okay, this PR also converts our current PUT to being PATCH (that's what it was) and support for real PUT: create like POST if doesn't exist, update if a full body is given, (that is with an id, currently).

@thibaultcha thibaultcha force-pushed the feat/admin-api-content-type branch from fbd58c2 to ef09381 Compare May 16, 2015 00:08
@coveralls
Copy link

Coverage Status

Coverage increased (+0.36%) to 72.26% when pulling ef09381 on feat/admin-api-content-type into 888231c on master.

thibaultcha added a commit that referenced this pull request May 18, 2015
[feature] Admin API now supports form-encoded and json
@thibaultcha thibaultcha merged commit 5dc1aef into master May 18, 2015
@thibaultcha thibaultcha deleted the feat/admin-api-content-type branch May 18, 2015 12:58
ctranxuan pushed a commit to streamdataio/kong that referenced this pull request Aug 25, 2015
[feature] Admin API now supports form-encoded and json
hutchic added a commit that referenced this pull request Jun 10, 2022
* fix(ci) de-dup the test Docker files

* chore(variable) use the correct variable

* chore(docker-kong) use master to build the test images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants