在Express(通过连接)处理文本/ plain [英] Handling text/plain in Express (via connect)?

查看:157
本文介绍了在Express(通过连接)处理文本/ plain的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Express 3,并希望处理 text / plain POST。

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

Express 3使用 connect's bodyParser 现在(我认为旧的Express代码被移动到连接)。 bodyParser的文档提供了有关如何使其支持其他文件类型的一些详细信息。而且,我发现一篇关于处理文字/原文在旧版本Express 中完成的优秀博客文章)

Express 3 uses connect's bodyParser now (I think the old Express code got moved to connect). The documentation for bodyParser gives some details about how to make it support additional file types. And I found an excellent blog post about how handling text/plain was done in old versions of Express).


  • 我应该明确要求连接(并让节点需要缓存修改版本)?或者通过express在某处连接暴露?

  • Should I explicitly require connect (and let node's require cache the modified version)? Or is connect exposed via express somewhere?

connect.bodyParser没有parse键。

connect.bodyParser does not have a 'parse' key.

如何使Express(通过连接)处理文本/纯文本?

How can I make Express (via connect) handle text/plain POSTs?

推荐答案

使用 bodyParser 作为依赖,将其添加到您的 app.js 文件中。

With bodyParser as dependency, add this to your app.js file.

var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.text());

Happy Noding。

Happy Noding.

这篇关于在Express(通过连接)处理文本/ plain的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆