Giter Site home page Giter Site logo

method-override's People

Contributors

dougwilson avatar jonathanong avatar mikaa123 avatar radagaisus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

method-override's Issues

Why not support this from GET?

It seems we could not overwrite the method with a GET request.
What if we detect in both req.body and req.query?

// req.body
    if (req.body && typeof req.body === 'object' && key in req.body) {
      method = req.body[key].toLowerCase();
      delete req.body[key];
    }

req.body is empty when using PUT method

All is fine when using the POST method. But when using PUT , req.body is empty.
And the following code structure i wrote:

Middlleware
app.use(bodyParser.urlencoded({extended: false}));
app.use(methodOverride('_method'));

HTML form
form action="/admin/edit-product/<%= product._id%>?_method=put" enctype="multipart/form-data"

Route
router.put('/edit-product/:id',function(req, res){ console.log(req.body); });

No req.body checking; do query string checking

Looking in req.body is absolutely non-standard and has a big problem where the entire request body needs to be parsed before this middleware is invoked, which doesn't make any sense. I haven't seen any other method override lib support body lookups. Really, this was just a bad decision to use req.body .i.m.o

app.use() requires middleware functions

After your last update on news projects i detect this error. Actually this error first show on express/lib/application.js:209:11 but later on our server file it shows on app.use(methodOverride('X-HTTP-Method-Override')); line.

Restrict HTTP method the override can arrive in

This module will accept the method override from any method. It should probably be restricted to only certain methods (user configurable?) like only POST (the default?). The only real purpose for this module is to allow legacy systems to make a different method call than they are capable of, and really, every client can POST and POST requests typically contain bodies, so I don't see a use-case to accept method-overrides in other methods (you can always POST with no body as well).

@jonathanong @Fishrock123 @defunctzombie thoughts?

Why make the way to override method exclusive?

AFAIK, there are at least three ways to override request method:

  1. via { X-HTTP-METHOD-OVERRIDE: PUT } header
  2. via ?_method=PUT
  3. via req.body._method

In my not so complicated application which was built with express 3, there are two ways of them involved already. And as far as I can tell, we can't ditch NO. 2 and 3 completely unless the application we are implementing is totally asynchronized with JavaScript.

So why make the way to override exclusive?

Not really an issue / more of a question

Can anyone tell me what would be the equivalent of:

<form action="/campaigns/revive/<%= revive._id %>?_method=DELETE" method="post">
    <button>Delete</button>
</form>

in pug / jade?

Not an actual issue

I just want to thank you. You saved me a lot of time (and headaches)
I'm building a framework on top of express and this is exactly what I needed ;)
Framework is Saturnial (name suggestions accepted)
You rock!

Case sensitive?

Is the header (e.g. in methodOverride('X-HTTP-Method-Override')) case sensitive?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.