-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Conversation
amazing! been waiting for this! good work! 👏 this will also make the documentation so much cleaner! |
f021278
to
beb9d4e
Compare
- `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.
0497eea
to
e9e56ea
Compare
@ahmadnassri @nijikokun who updates the doc? |
We'll do it when finished and merged |
4456850
to
fbd58c2
Compare
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 |
fbd58c2
to
ef09381
Compare
[feature] Admin API now supports form-encoded and json
[feature] Admin API now supports form-encoded and json
* fix(ci) de-dup the test Docker files * chore(variable) use the correct variable * chore(docker-kong) use master to build the test images
parse_params()
is a custom Lapis helper which parses form-encoded or application/json parameters. If sending form-encoded, it will un-nest keys likevalue.object=123
to{value={object=123}}
?key[1]=val
being parsed as{["1"]="val"}
. it is now properly parsed as{"val"}
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.