Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebp
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Endpoint Handlers
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

API contacts.GET
API contacts.HEAD

    Method  = HTTP_Services('GetHTTPRequestMethod')
	// If the GET method then return a body. If the HEAD method then just return response headers.
    .
    .
    .
    .

end api


URI URL Templates and HAL

URI Templates (URL Templates going forward) were introduced in 2012 as a way of documenting the structure of a URL , along with (including any query params, so that a process can build valid resource URL. It is also a useful for RESTful applications that simply want to provide self-documenting APIs. The HAL specification provides support links that are URI ). One primary purpose for URL Templates is for "the discovery of available services". This fits very well with the REST constraint of "resource identification". Simply put, a URL Template is an abstraction (or generic version) of a resource URL. A templated version of a URL contains arguments surrounded by curly braces like so:

https://www.examples.org/api/contacts/{contactID}

The HAL specification provides support links that are URL Templates (versus resource links). To help support URL Templates, the AddLinkRelation service (a member of HTTP_Resource_Services) has been updated with new arguments to make it easy to include a URL Template. Any valid resource URL within the system can be passed into the URL argument and if the IsTemplate argument is set to 1, then it will be converted to a URL Template. For example, the SRP HTTP Framework automatically ships with a Contacts resource which can be accessed via this URL:

https://www.examples.org/api/contacts

There are three query params supported by this resource: first_name, last_name, and state. If the above URL is passed into the AddLinkRelation service with the IsTemplate argument is set to 1, then resulting URL will look like this:

https://www.examples.org/api/contacts{?first_name,last_name,state}

The act of converting a URL Template into a valid resource URL is called "expansion". This is something a consumer for service might consider building. However, at a minimum, any human agent can review the URL Template your provide and benefit from your self-documenting APIs...which is a major objective of REST! it was never implemented in the SRP HTTP Framework...until now! API developers simply need to pass in a 1 in the new IsTemplate argument for the AddLinkRelation service.

4.0.5

More Logging TLC

The more logging gets used the more ways we see how this can be improved. Here is a summary of what we've added:

...