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

Matthias Wessendorf matzew at apache.org
Thu Apr 11 07:20:55 EDT 2013


On Thu, Apr 11, 2013 at 12:14 PM, Sebastien Blanc <scm.blanc at gmail.com>wrote:

>
> 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
>

assuming you want to access: http://www.slackers.com/security/team, I'd
expect that /team fails, since that would mean:
http://www.slackers.com/team(getting rid of the security part in the
URI)




> ```
> 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 ``` / ```.
>


sounds right - however I guess the "resource" can be simply appended to the
underlying library, at least in iOS land this is easy:

    NSURL *url = [NSURL URLWithString:@"http://server.com/security"];
    url = [url URLByAppendingPathComponent:@"/foo/bar"];

===>     http://server.com/security/foo/bar




>
> 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
>
>
> _______________________________________________
> aerogear-dev mailing list
> aerogear-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/aerogear-dev
>



-- 
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20130411/817f1f7b/attachment.html 


More information about the aerogear-dev mailing list