Handling text/plain in Express (via connect)?

前端 未结 5 795
轻奢々
轻奢々 2020-12-15 01:37

I am using Express 3, and would like to handle text/plain POSTs.

Express 3 uses connect\'s bodyParser now (I think the old Express code got moved t

5条回答
  •  醉话见心
    2020-12-15 02:11

    I would just make a module similar to the json.js middleware module and just don't bother converting the buf data into anything else. Wrap it into a plain.js file, apply some decent "don't repeat yourself" refactoring, and submit a pull request to connect. Seems generally handy. However, note that while convenient, large enough request bodies will require streaming straight to disk at some point so you don't consume all the memory in your node server.

提交回复
热议问题