| Description: |
::rest has the ability to handle URL arguments very well like so:
=======================================================
set google(search) [list\
method get\
url "https://ajax.googleapis.com/ajax/services/search/web"\
req_args [list q:]\
static_args [list v 1.0]\
result json]
::rest::create_interface google
set response [::google::search -q "tcllib"]
=======================================================
Turns out rest can also handle argument embedded INSIDE the URL, but its undocumented- if you add %varname% to the URL, the rest package will treat it as an argument to the point where the following works:
=======================================================
set jira(issue) [list\
method get\
url "https://jira.blank.com/rest/api/2/issue/%issueId%/otherPath/thing/"\
auth basic\
content-type "application-type"\
callback myCallback\
result json]
::rest::create_interface jira
after 5000 {set ::done 1}
::jira::issue -issueId JIRA-1234
::jira::issue -issueId JIRA-1235
vwait done
=======================================================
Which is awesome! What is not so awesome is that the ::rest::describe function does not recognize this argument, and its mostly undocumented. The only mention of this behavior in the docs is ::rest::substitute, but it only describes this exact substitution functionality. What isn't clear is that this is run on every URL. Its extremely useful (some of our internal routes of variables right in the middle:/) but it took us reading the rest.tcl code to understand this.
You also cant replicate this behavior with the standard req/static args functionality, the only way to get arguments in the middle of a URL is this (awesome)hidden method. Could the documents reflect this functionality, and somehow let ::rest::describe know about it? Or if its unintended behavior, could we have a method to do this?
|