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

API created with 'path' can not have a name #547

Closed
thibaultcha opened this issue Sep 17, 2015 · 10 comments
Closed

API created with 'path' can not have a name #547

thibaultcha opened this issue Sep 17, 2015 · 10 comments
Assignees
Labels

Comments

@thibaultcha
Copy link
Member

$ http POST :8001/apis path=/mockbin upstream_url=http://mockbin.com
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Server: kong/0.5.0
Transfer-Encoding: chunked

{
    "created_at": 1442503117000,
    "id": "d96aaf1a-8d06-4ecc-cea4-9c21ac3da416",
    "path": "/mockbin",
    "upstream_url": "http://mockbin.com/"
}
@lucamaraschi
Copy link

👍

@subnetmarco
Copy link
Member

This is in a way related to #489, because the easy fix for this would be to make name = request_path. Because the request_path contains slashes though, then we incur into issue #489.

@thibaultcha
Copy link
Member Author

In my implementation I replace slashes (except the first one) by dashes. But that is not a problem anymore, consider this resolved, the real issue here is #489. Are we satisfied with forbidding reserved characters or do we want to allow them and deal with percent-encoded URI parameters?

@subnetmarco
Copy link
Member

@thibaultcha i would forbid them, or slugify them

@thibaultcha
Copy link
Member Author

That also means no more spaces.

@subnetmarco
Copy link
Member

Slugifying parameters also brings some new issues:

  • We need to make sure the slug is unique
  • We need to make sure it gets updated every time the property is getting updated

Although slugs are the de-facto solution to this problems pretty much everywhere in the web.

I don't know. What's your idea on this issue?

@thibaultcha
Copy link
Member Author

No, slugs have never been a solution for me because I think it is better to refuse a value if it contains invalid characters than unpredictably change them, which is a confusing experience.

However, when the name is not specified, and is taken from the request_path, it replaces slashes by dashes. That is my current implementation in a local branch.

@subnetmarco
Copy link
Member

@thibaultcha so the following request_path: /helloworld becomes -helloworld ?

Makes sense to remove the first and last slash too maybe?

@thibaultcha
Copy link
Member Author

Obviously, already done.

thibaultcha added a commit that referenced this issue Sep 22, 2015
- API names cannot contain characters from RFC 3986 reserved characters
  list. If such a character is detected, it is a schema error and the
  creation/update is refused.
- This also sets an API's name to the given `request_path` if no
  `request_dns` is set. The first slash is omitted and subsequent
  slashes are replaced with dashes.
- Since spaces are not allowed anymore in API names, fixture APIs must
comply too.

See #547, #489
@thibaultcha
Copy link
Member Author

See #560 for both those issues. If restricting characters in an API names is what we chose, then it is the fix. I believe it is reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants