Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RESTful hypermedia, relative or absolute URI's

Tags:

rest

uri

I have just read the book REST in Practice: Hypermedia and Systems Architecture and am now trying out some of the ideas but cannot figure out whether to use absolute or relative URIs in my response documents.

I would prefer the abosulte URIs but can see that there will be a problem when going to production, where the server infrastructure with load balancer, apache rewrites, and Tomcat servers would overwrite the original URI and mess up my URI-generate mechanism, information such as the scheme and the context path will be rewritten or lost when it hits the Java code, and the URIs will not be correct from the clients point of view.

I then get tempted to just use relative URIs but is that a good idea or a wrong turn to take?

The book is persistent in using absolute URIs, but I cannot find any mentions regarding this. Martin Fowler wrote about Richardson Maturity Model and he's using relative URIs.

What do you think? pros/cons?

like image 805
drankard Avatar asked Nov 06 '22 01:11

drankard


1 Answers

I use relative URIs in many of my representations. My representations tend to be xml based so I make sure I include an xml:base attribute so it is clear where the relative URI is based.

like image 124
Darrel Miller Avatar answered Nov 09 '22 14:11

Darrel Miller