Comments (1)
For POST
instead of PATCH
use HttpMethodOverrideMiddleware
public void Configure(IApplicationBuilder app)
{
app.UseHttpMethodOverride();
app.UseMvc();
}
For PUT
instead of PATCH
create custom middleware
public class MethodOverrideMiddleware
{
private readonly RequestDelegate _next;
readonly string[] _methods = { "DELETE", "PATCH", "PUT" };
const string _header = "X-Http-Method-Override";
public MethodOverrideMiddleware(RequestDelegate next)
{
_next = next;
}
public Task Invoke(HttpContext context)
{
if (HttpMethods.IsPut(context.Request.Method) && context.Request.Headers.ContainsKey(_header))
{
var method = context.Request.Headers[_header].ToString();
if (_methods.Contains(method))
{
context.Request.Method = method;
}
}
return _next.Invoke(context);
}
}
and use it in Startup.cs
app.UseMiddleware<CustomMethodOverrideMiddleware>();
from simple.httppatch.
Related Issues (12)
- Add unit tests for Patch class HOT 2
- Add support Patch for collections HOT 1
- Prepare config to pack and publish NuGet package HOT 2
- Tips, improvements, suggestions HOT 1
- Excluding properties
- Ignore null value for specified properties
- Add possibility to create Patch model HOT 2
- .net 5 & C# 9
- Upgrade to .NET 6 HOT 3
- Tips, improvements, suggestions
- The TrySetMember method is not working; it doesn't execute. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple.httppatch.