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] new array type for schema fields #277

Merged
merged 1 commit into from
May 29, 2015
Merged

Conversation

thibaultcha
Copy link
Member

  • Useful for lists such as {"apikey", "key"}
  • Can be aliased to a comma-separated string: "apikey,key"

In form-encoded mode (JSON would be a real array), the Admin API accepts the following:

$ curl --url http://localhost:8001/apis/mockbin/plugins \
  -d "name=keyauth" \
  -d "value.key_names[1]=apikey" \
  -d "value.key_names[2]=key"

Or:

$ curl --url http://localhost:8001/apis/mockbin/plugins \
  -d "name=keyauth" \
  -d "value.key_names=apikey,key"

- Useful for lists such as {"apikey", "key"}
- Can be aliased to a comma-separated string: "apikey,key"

In form-encoded mode (JSON would be a real array), the Admin API accepts
the following:

```shell
$ curl --url http://localhost:8001/apis/mockbin/plugins \
  -d "name=keyauth" \
  -d "value.key_names[1]=apikey" \
  -d "value.key_names[2]=key"
```

Or:

```shell
$ curl --url http://localhost:8001/apis/mockbin/plugins \
  -d "name=keyauth" \
  -d "value.key_names=apikey,key" \
```
@subnetmarco
Copy link
Member

So both formats will be supported?

@thibaultcha
Copy link
Member Author

That's what it says

@subnetmarco
Copy link
Member

It should also work for multipart/form-data requests. Support for multipart is already there, just make sure it works with:

curl --url http://localhost:8001/apis/mockbin/plugins \
  -F "name=keyauth" \
  -F "value.key_names[1]=apikey" \
  -F "value.key_names[2]=key"

and

curl --url http://localhost:8001/apis/mockbin/plugins \
  -F "name=keyauth" \
  -F "value.key_names=apikey,key"

@thibaultcha
Copy link
Member Author

That type of parsing happens on the Lapis side, so I'll try but it should work.

@subnetmarco
Copy link
Member

Back in the days I had to add this to support multipart/form-data: https://github.com/Mashape/kong/blob/master/kong/api/routes/base_controller.lua#L54-L56

Because for multipart data Lapis creates a table, and the value is stored inside of .content.

@thibaultcha
Copy link
Member Author

btw supporting application/json and x-www-form-urlencoded is also perfectly fine...

@subnetmarco
Copy link
Member

I need multipart for the SSL plugin, so the users can upload their certificates

thibaultcha added a commit that referenced this pull request May 29, 2015
[feature] new `array` type for schema fields
@thibaultcha thibaultcha merged commit 347216c into master May 29, 2015
@thibaultcha thibaultcha deleted the feature/arrays branch May 29, 2015 23:43
ctranxuan pushed a commit to streamdataio/kong that referenced this pull request Aug 25, 2015
[feature] new `array` type for schema fields

Former-commit-id: f8b370fea7fc518fe1e7f7ff0629b06e1250f26e
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.

2 participants