-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POST Method override #1325
Comments
Hello Josef, It can be implemented as a Router Wrapper. I can write a small builtin wrapper for that later on today. |
Just to be clear on this @Dexus , you want something like this, right?: app := iris.New()
app.Post("/path", func(ctx iris.Context){
// handle post
ctx.WriteString("post")
})
app.Delete("/path", func(ctx iris.Context){
// handle DELETE or POST with X-HTTP-Method == 'DELETE'
// -> req.Method = DELETE
ctx.WriteString("delete")
}) fetch("/path", {
method: 'POST',
headers: {
"X-HTTP-Method": "DELETE"
},
})
.then((resp)=>{
// resp == "delete" ? // <-------------
})).catch(...) |
That's exactly what I mean. I don't know if you can do the control via form field as well. In the past, with Nginx and Apache, I had both the header and the form variant (input called _method). |
Nice! Don't worry, it will be based on the resources you posted above:
|
@Dexus it's done. Please test it in your app whenever you have time. import "github.com/kataras/iris/middleware/methodoverride" Test (&Example): https://github.com/kataras/iris/blob/master/middleware/methodoverride/methodoverride_test.go. iris/middleware/methodoverride/methodoverride_test.go Lines 12 to 26 in a14a345
Override all default values with: |
Works as expected and now makes it easier to use appropriate APIs under firewall fire. Thank you very much @kataras! |
Nice! You are welcome @Dexus! I thank you for the feature request |
Former-commit-id: e476998d8d6b10dc641b3393577937269adb694c
Former-commit-id: 9febac1ba701b29e59d7660540f03217f12cf9e0
Hello @kataras,
would it be possible to add a optional "Method Override"?
Like https://www.npmjs.com/package/method-override or http://fandry.blogspot.com/2012/03/x-http-header-method-override-and-rest.html
While some Firewalls do not support PUT, DELETE or PATCH request, I would like to know what would the best way to implement it for requirements like this.
Best Regards, Josef
The text was updated successfully, but these errors were encountered: