Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a bulk constructor to the ResourceLinker #1

Closed
wants to merge 1 commit into from

Conversation

ciaranj
Copy link

@ciaranj ciaranj commented Jul 23, 2012

Hi, I'm currently experimenting with options for HATEOAS components for my RESTful API ;) , so have been taking a looksy at your implementation of JSON+Hal.

I use Spring as my IoC container and struggled to configure your 'ResourceLinker' class effectively in my environment.

To combat this I added a fairly brutal new constructor to the class to allow all the resource linkers to be specified up front, in theory that might be useful to others too :)

Example config looks like this :

<object id="ResourceLinker" type="WebApi.Hal.ResourceLinker" singleton="true" lazy-init="true">
  <constructor-arg>
    <dictionary key-type="System.Type" value-type="System.Object">
      <entry value-ref="AppleLinker"><key><expression value="T(MyAPI.Resources.AppleResource)"/></key> </entry>
    </dictionary>
  </constructor-arg>    
</object>

Hope it helps.

@JakeGinnivan
Copy link
Owner

Hey,

Thanks. I will be working on this tonight, the resource linker is pretty clunky at the moment and I plan on cleaning it up. I will either pull this in, or give you a nicer approach very soon

@ciaranj
Copy link
Author

ciaranj commented Jul 23, 2012

I'm looking at creating some spring factories to 'hunt and gather' linkers so I don't need to define them, fwiw :)

@JakeGinnivan
Copy link
Owner

If they are simple I might just add into the Wiki once I settle on the API, I will be using autofac so I will have a similar setup for it.

@JakeGinnivan
Copy link
Owner

I have added an overload which will find and register all linkers from an assembly if that helps

@ciaranj
Copy link
Author

ciaranj commented Jul 30, 2012

Cool, sounds like what I was doing too. Incidentally the more I'm working in this area the more I'm thinking that what's currently down as a 'Resource' and 'ResourceLinker', might (possibly?) be more accurately named 'Representation' and 'RepresentationLinker', and the ApiController is closer to the actually 'Resource' (where resource maps onto URI, and Representation is what is returned from methods) ... what do you think?

@JakeGinnivan
Copy link
Owner

Good point actually, representation is a better name. Have a look at the latest additions, there is a heap new code in there which has been added over the last few days

@ciaranj
Copy link
Author

ciaranj commented Jul 30, 2012

Ok, will do.

panmanphil pushed a commit that referenced this pull request Dec 11, 2018
* engine is able to respond with empty resource collection

* unit test for resource list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants