Skip to content
This repository was archived by the owner on Jul 20, 2020. It is now read-only.
This repository was archived by the owner on Jul 20, 2020. It is now read-only.

Accessing Root object when creating links in embbedded items #12

Open

Description

@danice

To define links in embbedded items frequently is neccessary to have access to parent node info.

For example if we have a "folder" resource with a "self" link [folder], usually each of its items will have a "self" link as [folder]/[item]. To generate each item "self" link it needs all info in its parent object.

What I propose is to use the same

.Links((model, context) =>

,but extending context to not only contain NancyContext, but to be "custom" a HalContext with

public class HalContext
{
    public NancyContext NancyContext { get; set; }
    public Object Root { get; set; }
}

To mantain compatibiltiy with existing code we could have something like

public HalTypeConfiguration<T> Links(Func<T, NancyContext, Link> linkGetter)
{
    Func<T, HalContext, Link> halLinkGetter = (t, context) => linkGetter(t,context.Nancy);
    AddLinkFn(halLinkGetter);
    return this;
}

What do you think?
...and of course, i'm not asking you to do this.. i could implement this (or the solution proposed) myself.

Activity

  1. danbarua commented on Nov 25, 2014

    @danbarua
    Collaborator

    Of course, have a go at it and send a pull-request if you think this would work.

    Take a look at https://github.com/DotNetHypermedia/DotNetHypermedia - lots of us who are using hypermedia and writing hypermedia libraries are looking at how we can collaborate on sharing features and ideas together for a common hypermedia project - so the more ideas we can generate the better.

  2. danbarua commented on Nov 25, 2014

    @danbarua
    Collaborator

    In particular, the discussion is in the issues but we're working on spiking rough ideas out in code too https://github.com/DotNetHypermedia/DotNetHypermedia/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions