jgraichen / restify

Restify is a experimental, parallel and pipelined Hypermedia API client
GNU Lesser General Public License v3.0
8 stars 2 forks source link

Missing URI template params can cause wrong URL to be resolved #3

Closed franzliedke closed 7 years ago

franzliedke commented 8 years ago

Example:

Restify.new('http://host/articles/{id}`).get(id: nil).value

This will result in http://host/articles being requested - resulting in errors like:

Even though this usually results in an exception that will sooner or later lead to this realization, maybe unresolvable template parameters like {id} in the example should throw an exception instead?

jgraichen commented 7 years ago
3.2.1.  Variable Expansion

   A variable that is undefined (Section 2.3) has no value and is
   ignored by the expansion process.  If all of the variables in an
   expression are undefined, then the expression's expansion is the
   empty string.

URI templates [RFC 6570] do not have mandatory expressions. I do not see much we can do here. One has to check for errors (410, 404, 5xx) and expected content (Accept, Content-Type, Format, ...) anyway.

franzliedke commented 7 years ago

Okay, good point then.