Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Made the Negotiator awaitable #2422

Closed
wants to merge 1 commit into from

Conversation

thecodejunkie
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified made sure that I am following the Nancy code style guidelines
  • I have provided test coverage for your change (where applicable)

Description

Enables the use of Negotiator from inside an async module by calling await on it. This approach still enables the non-await call to it from inside LegacyNancyModule

public class TestModule : NancyModule
{
    public TestModule() : base("asyncnegotiator")
    {
        Get["/"] = async (parameters, ct) =>
        {
            return await Negotiate
                .WithModel(new RatPack { FirstName = "Nancy " })
                .WithMediaRangeModel("text/html", new RatPack { FirstName = "Nancy fancy pants" })
                .WithView("negotiatedview")
                .WithHeader("X-Custom", "SomeValue");
        };
    }
}

@thecodejunkie thecodejunkie added this to the 2.1 milestone Apr 22, 2016
@thecodejunkie
Copy link
Member Author

Just realized that this will automatically solve #2421 as well, since View["..:"] ultimately returns a Negotiator instance as well 😛

@grumpydev
Copy link
Member

Cool

@thecodejunkie
Copy link
Member Author

@NancyFx/most-valued-minions ⌚

@thecodejunkie
Copy link
Member Author

Replaced by #2441

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants