mdsol/crichton — pull request #238 by chad-medi (2014-08-01 05:47:07+00:00)
Title: Real Critchon entry points response - DO NOT MERGE (yet)

@sheavalentine-mdsol
@mdsol/hypermedia-team
@miw0923

I've opened up this PR for discussion purposes. Currently, entry point output looks like this:

https://gist.github.com/chad-medi/6e0bea86a48679ff7f1a

Why? We are using a URI as a link relation since it is not registered with the IANA. Well, that sucks, especially since, from the hypermedia perspective, URLs are opaque; e.g., they have no meaning.

But there is a solution: to give this link meaning, with human readable link relation name using an alps profile. Quoting that spec:

``` text
2.2.7.3. Link Relation Values and 'id'

A 'descriptor' that defines a state transition establishes an extension link relation whose name is the unqualified URI of the descriptor. (e.g. rel="http://example.com/#purchased-by") However, within representations that include the defining ALPS document as a profile, the descriptor's 'id' may be used on its own as a registered link relation. (e.g. rel="purchased-by")
```

This PR adds this capability and uses crichton to produce the same hale+json as any other representation. The result of this PR looks like this: https://gist.github.com/chad-medi/e8496b7734f1f3446847

The profile looks like this: https://gist.github.com/chad-medi/eb72aded3341d208bbbc

Win! (Additonal wins are than it's now easier for wormhole to add pagination)

However, the problem is that, especially in the case of Wormhole, it needs to dynamically create the link relations. Hence, on the fly, I create the descriptor using an erb file:

https://github.com/chad-medi/crichton/blob/feature/true_hal_entry_points/lib/crichton/discovery/entry_points_descriptor.yml.erb

I do have some problems with this.

1. I have to make the application/hale+json request before I can make an application/alps+xml request to get the profile document. Sucks.
2. I'm really not sure what the effect is on crichton to add updated descriptors documents on the fly. It "seems" to be okay, but you guys need to tell me.
3. I've had to add [this hack](https://github.com/chad-medi/crichton/blob/feature/true_hal_entry_points/lib/crichton/descriptor/transition_decorator.rb#L19). Sucks...it doesn't seem like crichton can find the default state. (or something). i need some advice on this. This is what the auto-generated descriptor looks like: https://gist.github.com/986dc863aeb64863b232

So, this PR is not ready to merge until I get some advice and fix some outstanding problems.

Thoughts?