pkuwm commented on issue #810: Zookeeper REST endpoint still prepends slash when path already has leading slash URL: https://github.com/apache/helix/issues/810#issuecomment-591556618 > @pkuwm Why would users input a path with two leading slashes? It is not that the response is incorrect; it seems like it's a case of incorrect **usage**. @narendly - Statement: I **don't** think `/zookeeper//tmp/aa/bb` is a case of incorrect usage. I do believe it is a **valid** request. - Reasons: Typically, a REST endpoint is like `/resources`. If I would like to query a particular resource, I would do `/resources/{identifier}`. In code implementation, I would do ``` RESOURCES_ENDPOINT = "/resources"; // already defined somewhere as an endpoint constant identifier = "123"; uri = RESOURCES_ENDPOINT + "/" + identifier; // Is this a correct usage?? request(uri); ``` So, likewise, can I do the same? ``` ZOOKEEPER_ENDPOINT = "/zookeeper"; // already defined somewhere as an endpoint constant path = "/tmp/aa/bb/cc"; uri = ZOOKEEPER_ENDPOINT + "/" + path; // Is this a correct usage?? request(uri); ``` But current response gives bad request 400 for the request: `uri = ZOOKEEPER_ENDPOINT + "/" + path;` I would ask, did I do it wrong? Why? I would say this is definitely correct. But why could the service not handle my **correct** request? Vice versa, let's transform the request back: `/zookeeper/tmp/aa/bb` -> `/zookeeper{path}` -> `/resources{identifier}`. Is `/resources{identifier}` a correct REST design? The reason why zookeeperAccessor gets pathparam at `tmp/aa/bb` for request `/zookeeper/tmp/aa/bb` is, REST defines/expects `/resources/{id}` and `/zookeeper//tmp/aa/bb` so REST could parse correct path. I definitely understand why we don't want 2 slashes: when `/zookeeper//tmp/aa/bb` is manually requested and seen by people, it looks strange and we do want to make it look normal to users. Looking strange is because people usually see single slash, but it does not mean two slashes especially for this case is incorrect. On the other side, if the request is on code level and people don't see it, would it matter? No. But I would expect my correct code to work successfully.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
