comparison 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
comparison
equal deleted inserted replaced
4922:816b23e09c20 4923:c83b009b5bc5
165 "from" : "user@example.com", 165 "from" : "user@example.com",
166 "kind" : "message", 166 "kind" : "message",
167 "to" : "bot@rest.example.net", 167 "to" : "bot@rest.example.net",
168 "type" : "chat" 168 "type" : "chat"
169 } 169 }
170 ```
171
172 ### Which stanzas
173
174 The set of stanzas routed to the callback is determined by these two
175 settings:
176
177 `rest_callback_stanzas`
178 : The stanza kinds to handle, defaults to `{ "message", "presence", "iq" }`
179
180 `rest_callback_events`
181 : For the selected stanza kinds, which events to handle. When loaded
182 on a Component, this defaults to `{ "bare", "full", "host" }`, while on
183 a VirtualHost the default is `{ "host" }`.
184
185 Events correspond to which form of address was used in the `to`
186 attribute of the stanza.
187
188 bare
189 : `localpart@hostpart`
190
191 full
192 : `localpart@hostpart/resourcepart`
193
194 host
195 : `hostpart`
196
197 The following example would handle only stanzas like `<message
198 to="anything@hello.example"/>`
199
200 ```lua
201 Component "hello.example" "rest"
202 rest_callback_url = "http://hello.internal.example:9003/api"
203 rest_callback_stanzas = { "message" }
204 rest_callback_events = { "bare" }
170 ``` 205 ```
171 206
172 ### Replying 207 ### Replying
173 208
174 To accept the stanza without returning a reply, respond with HTTP status 209 To accept the stanza without returning a reply, respond with HTTP status