# Rom-http: Gateway and Dataset URI paths

**URL:** <https://discourse.rom-rb.org/t/rom-http-gateway-and-dataset-uri-paths/407>\
**Category:** Issues\
**Created:** [December 16, 2020, 2:07pm UTC](https://discourse.rom-rb.org/t/rom-http-gateway-and-dataset-uri-paths/407 "2020-12-16T14:07:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dchandekstark](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/dchandekstark/32/209_2.png) [@dchandekstark](https://discourse.rom-rb.org/u/dchandekstark)\
**Post date:** [December 16, 2020, 2:07pm UTC](https://discourse.rom-rb.org/t/rom-http-gateway-and-dataset-uri-paths/407/1 "2020-12-16T14:07:19Z")

</div>

Hi,

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:

```
def self.call(dataset)
      uri = URI(dataset.uri)
      uri.path = dataset.absolute_path
      [...]
end

```

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.

Thanks,  
David

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/solnic/32/279_2.png) [@solnic](https://discourse.rom-rb.org/u/solnic)\
**Post date:** [December 28, 2020, 8:34am UTC](https://discourse.rom-rb.org/t/rom-http-gateway-and-dataset-uri-paths/407/2 "2020-12-28T08:34:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dchandekstark](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/dchandekstark/32/209_2.png) [@dchandekstark](https://discourse.rom-rb.org/u/dchandekstark)\
**Post date:** [December 29, 2020, 10:43pm UTC](https://discourse.rom-rb.org/t/rom-http-gateway-and-dataset-uri-paths/407/3 "2020-12-29T22:43:15Z")

</div>

Sure.

The gateway URI includes a path element:

```
http://localhost:8983/solr/solrbee

```

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 [https://github.com/rom-rb/rom-http/blob/master/lib/rom/http/handlers/json.rb#L27-L29](https://github.com/rom-rb/rom-http/blob/master/lib/rom/http/handlers/json.rb#L27-L29)) 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
http://localhost:8983/select

```

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).

Thanks,  
David

---

<div class="post-metadata">

**Author:** ![dchandekstark](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/dchandekstark/32/209_2.png) [@dchandekstark](https://discourse.rom-rb.org/u/dchandekstark)\
**Post date:** [December 29, 2020, 10:48pm UTC](https://discourse.rom-rb.org/t/rom-http-gateway-and-dataset-uri-paths/407/4 "2020-12-29T22:48:16Z")

</div>

Just to add more context, here is the request handler I am using instead of the default one from rom-http: [https://github.com/dchandekstark/solrbee/blob/main/lib/rom/solr/request\_handler.rb](https://github.com/dchandekstark/solrbee/blob/main/lib/rom/solr/request_handler.rb).

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

–David

---

<div class="post-metadata">

**Author:** ![dchandekstark](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/dchandekstark/32/209_2.png) [@dchandekstark](https://discourse.rom-rb.org/u/dchandekstark)\
**Post date:** [January 6, 2021, 2:53pm UTC](https://discourse.rom-rb.org/t/rom-http-gateway-and-dataset-uri-paths/407/5 "2021-01-06T14:53:49Z")

</div>

Pull request submitted for this and a couple of other minor issues: [https://github.com/rom-rb/rom-http/pull/43](https://github.com/rom-rb/rom-http/pull/43).
