Rom-http: Gateway and Dataset URI paths


I am delving into rom-rb with particular interest in rom-http for interacting with a web service.

I noticed that the default behavior of the JSON request handler clobbers the path of the dataset URI with dataset.absolute_path:

      uri = URI(dataset.uri)
      uri.path = dataset.absolute_path

The default implementation of absolute path prepends dataset.base_path with a slash. The effect of the behavior is that the path of the gateway URI is ignored.

My question is whether this behavior is intentional. Of course one can explicitly set base_path to the full path, but that seems odd. The base HTTP endpoint of a service is often not the root path of the site, so wouldn’t it make sense to configure this in the gateway and let the “base_path” of the dataset be relative to the gateway URI path?

For the moment I am overriding the request handler to behave the way I expect, but I wonder how other folks are using the library. It seems very well designed, but this one point is puzzling me.


Could you provide an example of what’s happening vs what you think should happen instead?


The gateway URI includes a path element:


Now, if I create a container and initialize a repository, the URI of the underlying dataset has the correct URI (appending the base_path “select” to the gateway URI path):

irb(main):002:0> documents.root.dataset.uri 
=> #<URI::HTTP http://localhost:8983/solr/solrbee/select>

But the absolute_path of the dataset just uses the base_path prepended with a slash:

irb(main):003:0> documents.root.dataset.absolute_path
=> "/select"

irb(main):004:0> documents.root.dataset.base_path
=> "select"

As a result, the request hander (at effectively does this:

irb(main):009:0> uri = URI(documents.root.dataset.uri)
=> #<URI::HTTP http://localhost:8983/solr/solrbee/select>
irb(main):010:0> uri.path = documents.root.dataset.absolute_path
=> "/select"

And the URI for the request is now:

irb(main):011:0> puts uri

What I think should happen is that the path of the dataset URI should not be “fixed” – i.e. that it’s the responsibility of the gateway to set the base URI (as it does for the value of dataset.uri).


Just to add more context, here is the request handler I am using instead of the default one from rom-http:

(This project is a WIP, but this particular piece is solid enough.)


Pull request submitted for this and a couple of other minor issues:

1 Like