Flow control from user space


This is post is aimed at developers.

With the release of Boomla v0.4.1, the built-in sjs-3 interpreter landed support for inlining apps. Until now this was the privilege of the html-1 interpreter, which provided significantly less options to take advantage of the powerful runtime Boomla has to offer.


Let’s cut to the meat. This example prints hello world and inlines a gallery next to it.

var body = 'hello world'
var gallery = f.select('gallery')
body += os.inline(gallery)

This is precisely ONE function call. There is no process to start and stop. There is no process in the first place, thus you don’t need to monitor if it crashed. It’s just like a function call, yet the application that is run may even be written in a different programming language.

Error handling

If the application crashes, Boomla handles it for you and will return a nicely formatted error message. What about the HTTP status-code? Boomla will also update it for you.

3xx beats 2xx 4xx beats 3xx 5xx beats 4xx

Otherwise, the first status-code from the same group is returned. For example, if 2 files that are inlined return 2 redirections, the first one will take precedent.

Full control, no magic

Magic? No. While this form of using os.inline() is certainly the most convenient form, it does limit your options. What if you want to take full control over what is returned to the user? You can. The os.inline() call has other optional arguments, like the response file. The response file is the one that will be decorated with the response status-code, redirect location and head tags required by the inlined file. To catch these values and control yourself what you want to pass higher up the call-chain, just create an empty file and pass it to os.inline() instead of the response file.

This way you have the choice between convenience or full control.

Real-life use case

A typical example is a generic slideshow app. Generic, because it will show and slide anything you give it. Not only images. You could equally give it some text or a video player.

Here is the docs of os.inline().