mschwartz / SilkJS

V8 Based JavaScript Swiss Army Knife (and HTTP Server!)
https://github.com/decafjs/decaf
Other
323 stars 37 forks source link

"Actions" should allow for a return of data #17

Open moduscreate opened 12 years ago

moduscreate commented 12 years ago

whatever_action = function() { return '{ "success" : true}'; };

In an ideal situation, we should allow for actions to return anything up to the browser, if possible. This gives end developers the full flexibility to custom format strings, etc to be bubbled up to the browser.

mschwartz commented 12 years ago

Here's a common use case for not supporting your suggestion.

A WWW site has a private login restricted area. There are PDF files that only logged in users are allowed to see, but they're mixed in to some directory where someone does mass uploads of the things.

What I think you want to do is tag, like in the database, which PDF files are private and the rest are not.

So you implement a pdf_action() method that queries the database and redirects to some "can't see this" graphic if the pdf is private, or returns to let the httpd server's normal processing logic serve the pdf.

What happens in your scenario of you return undefined? return true? return false?