...
Before I describe the specific actions, you need to understand the structure of actions. Actions Like functions, actions have a name , a set of required parameters, and a set of optional parameters. Optional Unnamed parameters are specified using a with
clause followed first, in order, followed by a list of name-value pairs in any order. The name and value are paired using an equal sign (=
) and the name-value pairs are separated with the keyword and
:
Code Block | ||||
---|---|---|---|---|
| ||||
foo("hello", 5) with , x = "world" and , y = 6 + 5) |
This action has a name, foo
, and two unnamed parameters, "hello"
and 5
. The action also has two optional named parameters, x
with the value "world"
and y
with the value 11
. The parameters, required named and optionalunnamed, can be any valid KRL expression and will be evaluated prior to the action being taken. More formally, parameters are evaluated in applicative order.
...
Code Block | ||||
---|---|---|---|---|
| ||||
send_directive("say") with something = , {"something":"Hello World" }) {"directives": [{"options":{"something":"Hello World"}, "name":"say", "meta":{ "rule_name":"hello_world", "txn_id":"8FF45D92-7EDB-11DF-B34A-4BA9F4723EB4", "rid":"a16x66" } } ] } |
...
http:post(<expr>). This makes an HTTP POST
to the URL given by <expr>
. Any optional parameters in the optional qs
map are added as name-value pairs in the query string of the URL. This action is useful for interacting with external Web services that aren't formally part of KEA. For example, the following action makes an HTTP POST
to the given URL, form-encoding the optional parameter encoding q
and sending it as the body of the POST
:
Code Block | ||||
---|---|---|---|---|
| ||||
http:post("http://google.com/search"), withqs = q = {"q":"hello"}) |
send_raw(<type>). This returns raw content. This is especially useful for returning content with a mime-type different from application/json or returning raw JSON without the enclosing directive. See the send_raw()
documentation for more information.
...