3 ms·
It may smell, but clients that uses URL templates may still be RESTful. For this to work, 1.) the server must decorate the response with the proper resource typ
by buddydvd 15y ago
It may smell, but clients that uses URL templates may still be RESTful. For this to work, 1.) the server must decorate the response with the proper resource type identifier, 2.) the client must be able to understand the resource type, and 3.) the resource type spec must specify how the clients should treat URL templates.
Web browsers are REST clients that understand the HTML resource type. They, too, can generate URLs. For example, in HTML, you can specify a URL template with the following code:
<form action="foo/bar/" method="get">
<input name="baz" type="text">
<input type="submit" value="Submit" />
</form>
Input tags with type="text" are, by default, optional. Newer HTML spec allows you to annotate input tags with the "required" attribute, which allows you to specify them as required.
You can define your custom resource type to do the same if you want:
{ "form": { "action": "foo/bar/",
"method": "GET",
"fields": [ { "name" : "baz" } ]
}
You can make the above example a lot leaner by trimming out features you don't care about. It's all up to how you design the spec of your resource type.