stubailo / meteor-rest

:sleeping: simple:rest - make your Meteor app accessible over HTTP and DDP alike
https://atmospherejs.com/simple/rest
MIT License
382 stars 85 forks source link

How to serve a static file with simple-rest #148

Open morphogencc opened 6 years ago

morphogencc commented 6 years ago

By defining a Meteor method, I can return a JSON Object as such:

Meteor.method("returnJsonObject", function() {
    return { "test" : "this is a test" }
});

If I send a GET request to http://localhost:3000/methods/returnJsonObject, this returns plain text just as I expect.

If I want a browser to be redirected here and automatically download this text as a file, such as "download.json", then I need to be able to update the response headers to indicate this is a file.

Is it possible to access the response headers in order to serve a file like this? I checked the unit tests and couldn't find an example...