RESTful hypermedia, relative or absolute URI

I just read the book REST in Practice: Hypermedia and Systems Architecture , and now I'm trying to work out some ideas, but I can’t understand whether to use absolute or relative URIs in my response documents.

I would prefer an abosulte URI, but I could see that there would be a problem when the server infrastructure with load balancer, apache overwrite and Tomcat servers overwrite the original URI and ruin my URI generation mechanism, information such as the schema and context path, will be overwritten or lost when it hits Java code, and the URIs will not be correct from the point of view of clients.

I am tempted to just use relative URIs, but is this a good idea or a wrong turn?

The book is persistent in using absolute URIs, but I cannot find any mention of this. Martin Fowler wrote about Richardson's maturity model, and he used relative URIs.

What do you think? pros / cons?

+5
source share
2 answers

I use relative URIs in many of my views. My views are usually xml based, so I include the xml: base attribute, so it’s clear where the relative URI is.

+2
source

URI , / /, , , URI, URI .

0

All Articles