New in this release is the ability to write your own request handlers in JavaScript.#
I added this feature because I wanted to try writing my own handlers without having to update Fargo Publisher. #
If a request comes in that doesn't match any of the built-in functions, we check the scripts sub-folder of the data folder. If an item matches, we eval it and return the result.#
How matching works: If the request is for /xyz then we look for xyz.js.#
We convert the request to lowercase, so that requests are case-insensitive, however the files in the folder must have all lowercase names. #
If we don't find it, we return 404. If there's a script error we return a 503.#
If the script is in count.js and the server is running at pub.fargo.io, you'd access it through this URL: http://pub.fargo.io/count. You can try it, click the link. Reload the page. Every time you load it, the count should increment.#
globals is a global object that you can hang persistent values on. They persist for the life of the server, when it's rebooted it's reset. You can think of it as a scratchpad. #
Here's the source for the server. To find the part that implements this, search for 404. We look in the scripts folder before calling it a Not Found error. #
I wrote a bit about this on Scripting News.#