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

Response Negotiator #1348

Merged
merged 6 commits into from Apr 3, 2014
Merged

Conversation

khellang
Copy link
Member

@khellang khellang commented Dec 3, 2013

OK, so this is most of the change I've been wanting to get in for a while (in #1213). It's basically ripping out the conneg parts from the DefaultRouteInvoker and putting them in a separate service IResponseNegotiator with it's default implementation DefaultResponseNegotiator.

I'd refactor (move) the tests as well, but it seems there's no unit tests for the conneg parts and 92% of the new response negotiator is covered by functional tests (the rest is trace calls).

The next step (for a future PR) would be to use this service to do conneg in other pipelines 馃槃

this.coercionConventions = coercionConventions;
}

public Response NegotiateResponse(object result, NancyContext context)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is very long. I'd do some extract methods. A few suggestions for where below.

@khellang
Copy link
Member Author

Sure, by all means. Some of the methods could be refactored. They're just a clean rip-out from the existing conneg stuff from DefaultRouteInvoker 馃槈 @thecodejunkie, @grumpydev what do you say?

@khellang
Copy link
Member Author

Alright @horsdal, what do you think now? I struggled a bit to grasp what the existing methods tried to accomplish, so I factored them a bit differently and added XML comments so anyone should be able to understand the basics of what's going on. Here's a map of the method calls:

image

I also took the liberty of replacing the IEnumerable<Tuple<string, IEnumerable<Tuple<IResponseProcessor, ProcessorMatch>>>> with IEnumerable<CompatibleHeader> since it reads a bit better and creates less noise when being passed around 馃槈

@horsdal
Copy link
Member

horsdal commented Dec 17, 2013

@khellang Much nicer factoring! The methods make a whole lot more sense to me now.
Also agree on encapsulating Tuple<string, IEnumerable<Tuple<IResponseProcessor, ProcessorMatch>>> in CompatibleHeader.

@grumpydev
Copy link
Member

I actually find Tuple<string, IEnumerable<Tuple<IResponseProcessor, ProcessorMatch>>> more readable :trollface: 馃槈

@realmerx
Copy link

+1

thecodejunkie added a commit that referenced this pull request Apr 3, 2014
@thecodejunkie thecodejunkie merged commit 8a5bf2e into NancyFx:master Apr 3, 2014
@khellang khellang deleted the response-negotiator branch April 3, 2014 08:03
@khellang khellang restored the response-negotiator branch February 20, 2015 12:08
@khellang khellang deleted the response-negotiator branch February 20, 2015 12:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants