diff mod_rest/README.markdown @ 4923:c83b009b5bc5

mod_rest: Add configuration of which stanzas to route to callback Makes it simpler to build APIs that only handle a certain kind of stanzas, letting them be handled by the unhandled stanza handler instead of having to write code to ignore certain kinds of stanzas.
author Kim Alvefur <zash@zash.se>
date Sat, 09 Apr 2022 01:04:25 +0200
parents bdac7c717c91
children a85efae90e21
line wrap: on
line diff
--- a/mod_rest/README.markdown	Sat Apr 09 00:43:18 2022 +0200
+++ b/mod_rest/README.markdown	Sat Apr 09 01:04:25 2022 +0200
@@ -169,6 +169,41 @@
 }
 ```
 
+### Which stanzas
+
+The set of stanzas routed to the callback is determined by these two
+settings:
+
+`rest_callback_stanzas`
+:   The stanza kinds to handle, defaults to `{ "message", "presence", "iq" }`
+
+`rest_callback_events`
+:   For the selected stanza kinds, which events to handle.  When loaded
+on a Component, this defaults to `{ "bare", "full", "host" }`, while on
+a VirtualHost the default is `{ "host" }`.
+
+Events correspond to which form of address was used in the `to`
+attribute of the stanza.
+
+bare
+:   `localpart@hostpart`
+
+full
+:   `localpart@hostpart/resourcepart`
+
+host
+:   `hostpart`
+
+The following example would handle only stanzas like `<message
+to="anything@hello.example"/>`
+
+```lua
+Component "hello.example" "rest"
+rest_callback_url = "http://hello.internal.example:9003/api"
+rest_callback_stanzas = { "message" }
+rest_callback_events = { "bare" }
+```
+
 ### Replying
 
 To accept the stanza without returning a reply, respond with HTTP status