您希望将原始文本数据发布到流中。
使用 HTTP In
节点监听 Content-Type
设置为 text/plain
的 POST 请求,并将发布的数据作为 msg.payload
访问。
[{"id":"3e1c5107.c1e3ae","type":"http in","z":"3045204d.cfbae","name":"","url":"/hello-raw","method":"post","swaggerDoc":"","x":120,"y":920,"wires":[["cf679478.309868"]]},{"id":"cf679478.309868","type":"template","z":"3045204d.cfbae","name":"page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n <head></head>\n <body>\n <h1>Hello {{ payload }}!</h1>\n </body>\n</html>","x":290,"y":920,"wires":[["f3c1a3f0.0c3e6"]]},{"id":"f3c1a3f0.0c3e6","type":"http response","z":"3045204d.cfbae","name":"","x":430,"y":920,"wires":[]}]
[~]$ curl -X POST -d 'Nick' -H "Content-type: text/plain" https://:1880/hello-raw
<html>
<head></head>
<body>
<h1>Hello Nick!</h1>
</body>
</html>
当 HTTP In
节点接收到 Content-Type
标头设置为 text/plain
的请求时,它将请求体作为 msg.payload
提供。
var name = msg.payload;
版权所有 OpenJS 基金会 和 Node-RED 贡献者。保留所有权利。OpenJS 基金会 已注册商标并使用商标。有关 OpenJS 基金会 商标列表,请参阅我们的商标政策和商标列表。未在OpenJS 基金会商标列表中指明的商标和徽标是其各自持有者的商标™或注册®商标。使用它们并不意味着与它们有任何关联或得到它们的认可。
OpenJS 基金会 | 使用条款 | 隐私政策 | OpenJS 基金会章程 | 商标政策 | 商标列表 | Cookie 政策