Before and after Livecode

David Bovill david at
Sun Jul 19 10:37:38 EDT 2015

Oh wow - it get's better.

Say you have a handler - that processes some information from a request and
then sends out a response. In my case the server bundles useful stuff into
a requestArray, and after it has been routed a handler processes it and
sends back a reply to the browser. The handler looks like this:

*command* process_UnGot socketID, requestArray
>    *put* requestArray ["someInput"] && "is flexible!" into someMessage
>    daemon_SendJSON socketID, someMessage
>    *return* "An ungot url path"
> *end* process_UnGot

So let's say we want to modify this processing in some way - but not touch
the code. We can override the handler, by using the same "process_UnGot" -
but what if we want to just modify the data and let the existing code do
it's thing. how can we put stuff into the requestArray without altering the
existing code?

Well damned me if you can't use the following before handler in another

before process_UnGot socketID, @requestArray
>    *put* "rubbish" into requestArray ["test"]
> *end* process_UnGot

Note the "@" - it's not in the original handler - but it still works!
Inject anything you want into any existing handler without messing with
your existing code. Middleware just got sexy.

On 19 July 2015 at 02:19, Mark Wieder <mwieder at> wrote:

> On 07/18/2015 12:28 PM, David Bovill wrote:
>  Now with before / after handlers - no logging code in the server - it's so
>> clean and simple it is gorgeous. When I want logging I add the behavior
>> which includes all the efore / after handlers that havve acess to all the
>> data and just do the logging. When I don;t want them I remove the
>> behavior.
>> Nice.
> Brilliant.
> --
>  Mark Wieder
>  ahsoftware at
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:

More information about the Use-livecode mailing list