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

Handler name should not be used as URL path as well #82

Closed
cheungpat opened this issue Nov 1, 2016 · 1 comment
Closed

Handler name should not be used as URL path as well #82

cheungpat opened this issue Nov 1, 2016 · 1 comment
Assignees

Comments

@cheungpat
Copy link
Contributor

cheungpat commented Nov 1, 2016

The solution described here was not implemented. However, the problem is resolved by wrapping all the request data in a JSON object, which is also a solution for the described problem.

(original issue description follows)


There is a problem with the way the handler are registered on both the plugin side and the server side: the URL path of the handler is also the name of the handler.

This pose a problem with the http transport in which the name of the handler will appear in the URL of the plugin call request. For example,

@handler('/hello/world')  # http plugin request with use `/handler/hello/world`
def handler(request):
    return "OK"

Having slash in handler names caused the http router in the plugin side to have problem matching requests.

To solve this problem, the plugin should generate a name for the handler and pass path information to the server:

# before
{
  "name": "/hello/world",
  "methods": ["POST"],
  "key_required": True
}
# after
{
  "name": "generated_handler_name",    // request become `/handler/generated_handler_name`
  "path": "/hello/world",
  "methods": ["POST"],
  "key_required": True
}

skygear-server should use path when registering the handler with http router. To be backward compatible, skygear-server should use name key if path does not exist.

@cheungpat cheungpat self-assigned this Nov 2, 2016
@cheungpat
Copy link
Contributor Author

After some offline discussion, we will not implement what is described here. We will accomplish the same thing by putting the name of the handler in a JSON-wrapped request body.

cheungpat added a commit to cheungpat/skygear-server that referenced this issue Nov 2, 2016
cheungpat added a commit to cheungpat/py-skygear that referenced this issue Nov 2, 2016
cheungpat added a commit to cheungpat/py-skygear that referenced this issue Nov 2, 2016
cheungpat added a commit to cheungpat/py-skygear that referenced this issue Nov 2, 2016
cheungpat added a commit to cheungpat/skygear-server that referenced this issue Nov 2, 2016
cheungpat added a commit to cheungpat/skygear-server that referenced this issue Nov 2, 2016
cheungpat added a commit to cheungpat/skygear-server that referenced this issue Nov 2, 2016
ben181231 pushed a commit to SkygearIO/skygear-server that referenced this issue Nov 3, 2016
@rickmak rickmak closed this as completed Nov 7, 2016
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

No branches or pull requests

2 participants