go - How to use URI as a REST resource? -


i building restful api retrieving , storing comments in threads.

a comment thread identified arbitrary uri -- url of web page comment thread related to. design similar disqus uses system.

this way, on every web page, querying related comment thread doesn't require storing additional data @ client -- needed canonical url page in question.

my current implementation attempts make uri work resource encoding uri string follows:

/comments/https%3a%2f%2fexample.org%2ffoo%2f2345%3ffoo%3dbar%26baz%3dxyz 

however, before dispatching application, request uri gets decoded server

/comments/https://example.org/foo/2345?foo=bar&baz=xyz 

this isn't working because decoded resource name has path delimiters , query string in causing routing in api confused (my routing configuration assumes request path contains /comments/ followed string).

i double-encode them or using other encoding scheme uri encode, add complexity clients, i'm trying avoid.

i have 2 specific questions:

  1. is uri design should continue working or there better (best?) practice doing i'm trying do?

  2. i'm serving api requests go process implemented using martini 'microframework'. there go or martini specific should make uri-encoded resource names stay encoded? perhaps way hint routing subsystem resource name not string url-encoded string?

i don't know url scheme application, single % encoded values valid in url in place of chars represent, , should decoded server, seeing expect. if need pass url reserved characters value , not have them decoded part of url, need double % encode them. it's common practice, complexity added client & server not much, , short comment rightly.

in short, if need pass url chars, double % encode them, it's fine.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -