Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Cache Common Header Values. #918

Closed
harshgMSFT opened this issue Aug 1, 2014 · 6 comments
Closed

Cache Common Header Values. #918

harshgMSFT opened this issue Aug 1, 2014 · 6 comments
Assignees
Milestone

Comments

@harshgMSFT
Copy link
Contributor

For Input and output formatters the supported media types should come from a cached pool. #868 , #896

@rynowak
Copy link
Member

rynowak commented Aug 1, 2014

Consider just making a static class with readonly instances on it and supporting instance of MediaTypeHeader in the ProducesAttribute.

Then you can write code like this:

[HttpGet("{id}")]
[Produces(MediaTypes.ApplicationJson, MediaTypes.ApplicationXml, Type = typeof(Product))]
public Product GetProduct(int id)
{
}

As a bonus our comparison for media types will generally just be a fast-path reference equality test.

@danroth27
Copy link
Member

Agree with @rynowak.

@rynowak rynowak self-assigned this Oct 30, 2014
@rynowak rynowak modified the milestones: 6.0.0-beta2, 6.0.0-rc1 Oct 30, 2014
@danroth27 danroth27 modified the milestones: 6.0.0-rc1, 6.0.0-beta2 Dec 11, 2014
@yishaigalatzer
Copy link
Contributor

@Tratcher do you think this kind of class belongs in HttpAbstractions for common Content types?

@yishaigalatzer yishaigalatzer modified the milestones: 6.0.0-rc1, 6.0.0-beta3 Jan 14, 2015
@Tratcher
Copy link
Member

I hesitate to provide statics like that because the header types like MediaTypeHeaderValue are mutable.

@yishaigalatzer
Copy link
Contributor

Depends on aspnet/HttpAbstractions#177

@danroth27 danroth27 modified the milestones: 6.0.0-beta6, 6.0.0-beta5 May 11, 2015
@Eilon Eilon modified the milestones: 6.0.0-beta6, 6.0.0-beta7 Jun 29, 2015
@Eilon Eilon modified the milestones: 6.0.0-beta7, 6.0.0-beta8 Aug 5, 2015
@Eilon Eilon modified the milestones: 6.0.0-beta8, 6.0.0-rc1 Aug 28, 2015
@Eilon Eilon modified the milestones: 6.0.0-rc1, 1.0.0-rc2 Oct 22, 2015
@rynowak
Copy link
Member

rynowak commented Nov 10, 2015

Closing this out after some discussion. The example provided above can't work because a MediaTypeHeaderValue can't be const, and so can't be used in an attribute.

If we have a perf issue, we'll drive it another way.

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

No branches or pull requests

7 participants