[aerogear-dev] Convention when passing baseURL, endpoints, id, resources ...

Sebastien Blanc scm.blanc at gmail.com
Thu Apr 11 06:14:48 EDT 2013


Hi,

Today when we set up a Pipe and call methods on it, we have a different
ways on how we can pass the  stuff which are part of the URI and more
particularly the leading or ending "/" :

```
baseURL: "http://www.slackers.com" //no ending slash
endpoint: "/security" //we have to start with a slash
```
But we can also do it the otherr way around :

```
baseURL: "http://www.slackers.com/" //ending slash
endpoint: "security" //no starting slash
```

Both are valid because our library (at least JavaScript) don't do any
manipulation for ```baseURL``` and ```endpoint```.

But if you take the parameter ```id``` on the ```read``` function, this one
must not have a leading "/" because it's added by the library:
```
id: "team1" //works
id: "/team" //fails
```
Until now ```id``` was the last part of the URI but since we are planning
to add nested resources, ```id``` won't be necessarily the last fragment.
For example, we could have a new parameter called ```resource``` to be
appended at the end :

```
baseURL = "http://www.slackers.com/" //ending slash
endpoint: "security" // no starting slash
id: "5" // handled by lib
resource: "/crypto" //leading slash needed
```
As the spirit of Pipes (at least for REST) is to offer an abstraction
around the Ajax and URL handling plumbing code, I think we should have a
convention for passing URI fragments that is the same for all. My
suggestion is to do the same as for ```id``` : no leading ``` / ``` or
ending ``` / ```.

If the user passes  a leading or ending ``` / ```, the library will removed
it because it will be added implicitly. This way we are safe.

Remarks ? Questions ?


  Seb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20130411/d5a5c30b/attachment.html 


More information about the aerogear-dev mailing list