Hey, I''m currently implementing a API for a website which is supposed to support following requests: /api/users/id/1 /api/users/email/test-hcDgGtZH8xNAfugRpC6u6w@public.gmane.org ... Of course the email address with its dot causes an error because if the .org which is interpreted as file format. How can I pass an email address like that? Thanks for the help, Hans -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Martin Wawrusch
2011-Oct-07 15:41 UTC
Re: API request with email in address path possible?
Interesting question. First of all I think you need to change this a bit into /api/users/1 as the canonical url and perhaps add a route like /api/users/search?email=youremail which redirects to the canonical url. On Fri, Oct 7, 2011 at 8:31 AM, Heinz Strunk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hey, > > I''m currently implementing a API for a website which is supposed to > support following requests: > /api/users/id/1 > /api/users/email/test-hcDgGtZH8xNAfugRpC6u6w@public.gmane.org > ... > > Of course the email address with its dot causes an error because if the > .org which is interpreted as file format. > > How can I pass an email address like that? > > Thanks for the help, > Hans > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Oh, yeah... I actually added the /id/ part by accident. So the only way to pass an email is by a paramter like ...?email=xxx? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Martin Wawrusch
2011-Oct-07 16:07 UTC
Re: Re: API request with email in address path possible?
It might be possible to pass it as part of the uri, but you do not want to do that because it would create a second url representing the same resource. Basically, you want to have one url per resource to make the API easy to use, and for things that are actually queries it is better to use parameters. Here is a simple example to illustrate the problem by adding voting to the user resource: /users/1/votes /users/email/martin-qs6+VQBngv1Wk0Htik3J/w@public.gmane.org/votes Which one is the correct one? Software developers would guess the first one, but machines would be clueless. And you would have to implement both routes to be consistent, then you would have to document it, and then you would hate programming :) On Fri, Oct 7, 2011 at 8:59 AM, Heinz Strunk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Oh, yeah... I actually added the /id/ part by accident. So the only way > to pass an email is by a paramter like ...?email=xxx? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
makes sense, thanks a lot for the explanation :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.