Many RESTful APIs simply have you indicate which version of the API you will be using by putting the version in the URL, e.g. (lhc:get "http://host/api/v2/order/124"). However, some REST APIs use the hypermedia way of telling the server which version you want. This requires setting an "Accept" header.
In lhc, you can do this in the following manner for a JSON service:
> (set version "application/vnd.api+json; version 2.3")
"application/vnd.api+json; version 2.3"
> (lhc:get "http://host/api/order/124"
(#("Accept" version))
(lhc:make-options))
It would be nice if lhc supported hypermedia versioning so that users could instead simply do this:
Many RESTful APIs simply have you indicate which version of the API you will be using by putting the version in the URL, e.g.
(lhc:get "http://host/api/v2/order/124")
. However, some REST APIs use the hypermedia way of telling the server which version you want. This requires setting an"Accept"
header.In lhc, you can do this in the following manner for a JSON service:
It would be nice if lhc supported hypermedia versioning so that users could instead simply do this:
or, to change the
+json
to+xml
:or, to completely override the mime-type:
These would then generated the appropriate HTTP header behind the scenes, obviating the user from having to do that.