Opened 9 years ago
Closed 8 years ago
#16691 closed defect (fixed)
[patch][cla] dojo.store.jsonrest cannot be used with REST servers that do support a trailing slash
Reported by: | rhunwicks | Owned by: | Kris Zyp |
---|---|---|---|
Priority: | low | Milestone: | 1.10 |
Component: | Data | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
I am working on a project using OpenLayers? and Dojo. I want to use the same REST service as the target for both OpenLayers?.Protocol.HTTP and Dojo.Store.JsonRest?. Both OpenLayers?.Protocol.HTTP and my REST server assume the the target URL for the REST service will not have a trailing slash i.e. to the the list of objects we have:
/foo
and to get one object we have
/foo/123
Dojo.Store.JsonRest? assumes that the target has a trailing slash, i.e. to get the list of objects we have:
/foo/
Because of this assumption, Dojo.Store.JsonRest? just appends the id to the target when attempting a GET or PUT:
return xhr("GET", { url: this.target + id, handleAs: "json", headers: headers });
This means that I cannot use my default server URL of /foo because it attempts to get /foo123 instead of /foo/123
In the old dojox.data.JsonRestStore? this behaviour was configurable using the allowNoTrailingSlash property.
I think we should either introduce allowNoTrailingSlash to Dojo.Store.JsonRest? or infer it from the supplied target - if the target does not have a trailing slash, then get(), put(), add(), and remove() should add one automatically and query() should use the target as it was supplied.
If I wanted to submit a fix myself, should that be as a patch to this ticket, or as a PR in GitHub??
Change History (8)
comment:2 Changed 9 years ago by
Should we automatically insert a slash if there is no trailing slash (and no query/question mark in the base url)?
We would prefer a patch, not a PR.
comment:3 Changed 9 years ago by
If the base URL doesn't contain a trailing slash then the methods that append an id - get(), put(), add(), and remove() - should insert a slash before the id.
I'll try and do a patch.
comment:4 Changed 8 years ago by
Milestone: | tbd → 1.10 |
---|---|
Priority: | undecided → low |
comment:5 Changed 8 years ago by
Summary: | dojo.store.jsonrest cannot be used with REST servers that do support a trailing slash → [patch][cla] dojo.store.jsonrest cannot be used with REST servers that do support a trailing slash |
---|
comment:7 Changed 8 years ago by
A much simpler and probably more efficient solution would just be to normalize target to add the slash, rather than calling a function every time target is referenced (which is what the provided pull request does).
comment:8 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Please see #8980 (dojox.rpc.Rest incorrectly adds trailing slash to target) for further background