Skip to content

Instantly share code, notes, and snippets.

@alexkolson
Last active December 21, 2015 00:58
Show Gist options
  • Save alexkolson/6223920 to your computer and use it in GitHub Desktop.
Save alexkolson/6223920 to your computer and use it in GitHub Desktop.
KRL rule that responds to an event (HTTP GET request) and returns some HTML.
// This rule would respond to an HTTP GET request to the following URL structure:
// https://cs.kobj.net/sky/event/CLOUD_ECI/EVENT_IDENTIFIER/andy_event/example_html/
// Where CLOUD_ECI is the event channel identifier for the cloud you want to raise this event into, and
// EVENT_IDENTIFIER is any unique identifier for an event. It can be anything as long as its unique.
// So for example, if my cloud ECI was 7B59AF40-AD1D-11E2-9896-9A82E71C24E1, I could trigger this rule by doing an HTTP GET to:
// https://cs.kobj.net/sky/event/7B59AF40-AD1D-11E2-9896-9A82E71C24E1/123456/andy_event/example_html/
// Note that any ruleset installed into this cloud could also respond to the example_html event
rule example_html_response {
select when andy_event example_html
pre {
example_html = <<
<div id = "blockity-block">Block elements are awesome!</div>
<span id = "inliny-line">Inline elements are cool too!</span>
>>;
}
{
send_raw("text/html")
with content = example_html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment