mccalltd / AttributeRouting

Define your routes using attributes on actions in ASP.NET MVC and Web API.
http://mccalltd.github.io/AttributeRouting/
MIT License
416 stars 89 forks source link

Add PATCH, HEAD, and OPTIONS attributes. #225

Open mccalltd opened 11 years ago

abpatel commented 11 years ago

Hi Tom, This is a coincidence. I was just searching of these very attributes in the AttributeRouting codebase today and stumbled upon this post. Do you have a ballpark ETA for this item? I am using AttributeRouting with WebAPI and would much like to use PATCH in my action methods accepting Delta for partial entity updates. TIA

mccalltd commented 11 years ago

No timeframe. You could just use [HttpRoute("url", HttpMethod.Patch)] for now.

On Mar 19, 2013, at 7:03 PM, abpatel notifications@github.com wrote:

Hi Tom, This is a coincidence. I was just searching of these very attributes in the AttributeRouting codebase today and stumbled upon this post. Do you have a ballpark ETA for this item? I am using AttributeRouting with WebAPI and would much like to use PATCH in my action methods accepting Delta for partial entity updates. TIA

— Reply to this email directly or view it on GitHubhttps://github.com/mccalltd/AttributeRouting/issues/225#issuecomment-15153260 .

abpatel commented 11 years ago

That was preceisley what I was trying to do but the HttpMethod does not seem to have a the "Patch" verb property on it. Am I missing something?

mccalltd commented 11 years ago

Hmm. I think you are missing something. Can try a spike in the next day or two. Should be there, though.

On Mar 19, 2013, at 8:31 PM, abpatel notifications@github.com wrote:

That was preceisley what I was trying to do but the HttpMethod does not seem to have a the "Patch" verb property on it. Am I missing something?

— Reply to this email directly or view it on GitHubhttps://github.com/mccalltd/AttributeRouting/issues/225#issuecomment-15155322 .

abpatel commented 11 years ago

My reference is coming from the following location. Look right?

System.Net.Http.dll, v4.0.0.0 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Net.Http.dll

abpatel commented 11 years ago

For now I ended up defining my own PATCH attribute like so: public class PATCHAttribute : HttpRouteAttribute { ///

    /// Specify a route for a GET request.
    /// </summary>

    /// <param name="routeUrl">The url that is associated with this action</param>
    public PATCHAttribute(string routeUrl) : base(routeUrl, new HttpMethod("PATCH")) {}
}

and decorating my actions like so: [PATCH("api/Products/{id}",RouteName="PatchProduct")] public HttpResponseMessage PatchProduct(string id,Delta productDelta) { //do whatever with the delta }

A side note: I have removed the "DefaultAPI" route from the WebAPIConfig.cs