Meteor 中的 JSON 端点 [英] JSON endpoint in Meteor
问题描述
有没有办法使用meteor 在页面中返回纯文本?假设有人请求了 domain.com/get/that-thing,我只想返回字符串52",以便请求者知道那个东西有52"的东西.据我了解,这在 Meteor 中是不可能的,因为总是包含标题等.
Is there a way to return straight text in a page using meteor? Say someone requested domain.com/get/that-thing, and I just wanted to return the string "52", so that the requester knows that-thing has "52" of something. To my understanding, this is not possible in Meteor because the headers and such are always included.
2 个可行的 hack:写入名为that-thing"的文件,以预期可能会调用that-thing".这在一般情况下不起作用.放置一个反向代理,将一些请求重定向到非流星后端.
2 hacks that would work: Write to a file named "that-thing" in anticipation that "that-thing" might be called. This doesn't work in the general case. Put a reverse proxy that redirects some of the requests to a non-meteor backend.
有没有更好的方法来做到这一点?
Is there a better way to do this?
推荐答案
Router 支持这个;查看服务器端路由:https://github.com/tmeasday/meteor-router
Router supports this; check out the server side routing: https://github.com/tmeasday/meteor-router
这篇关于Meteor 中的 JSON 端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!