gamache / hyperresource

A self-inflating Ruby client for hypermedia APIs. Not under active development.
http://hyperresource.com/doc
MIT License
304 stars 29 forks source link

Call to api.products does not wrong #34

Open kgish opened 9 years ago

kgish commented 9 years ago

I've verified my API server using the HAL-browser, but when I try hyperresource it doesn't search properly on the underlying products collection.

GET /products returns this:

{
  "_links": {
    "self": {
      "href": "/"
    },
    "curies": [
      {
        "name": "ht",
        "href": "http://localhost:8080:/rels/{rel}",
        "templated": true
      }
    ],
    "ht:products": {
      "href": "/products"
    },
    "ht:users": {
      "href": "/users"
    }
  },
  "welcome": "Welcome to Kiffin's Demo HAL Server.",
  "hint_1": "This is the first hint.",
  "hint_2": "This is the second hint.",
  "hint_3": "This is the third hint.",
  "hint_4": "This is the fourth hint.",
  "hint_5": "This is the last hint."
}

GET /products returns this:

{
  "_links": {
    "self": {
      "href": "/products"
    },
    "curies": [
      {
        "name": "ht",
        "href": "http://localhost:8080:/rels/{rel}",
        "templated": true
      }
    ],
    "ht:product": [
      {
        "href": "/products/1",
        "id": 1,
        "name": "bathtub",
        "category": "animal",
        "price": 4510
      },
      {
        "href": "/products/2",
        "id": 2,
        "name": "dragon",
        "category": "book",
        "price": 9617
      },
      ...
    ]
  }
}

GET /products/2 returns this:

{
  "_links": {
    "self": {
      "href": "/products/2"
    },
    "curies": [
      {
        "name": "ht",
        "href": "http://localhost:8080:/rels/{rel}",
        "templated": true
      }
    ]
  },
  "name": "dragon",
  "category": "book",
  "price": 9617
}

So far so good. However, following the documentation verbatim, here's what I see:

api.get => GET /
api.products => GET /
api.products(id: 2) => GET /products

I have the following questions: