How do I define my own endpoints to receive and consume external events?

Is it possible to define my own endpoints in the wiki, so that my plugins could consume external events?

For example, I’d like to define an endpoint like this where an external service could send the events:

https://snawaz-wiki.com/slack/consume-events

Also, I don’t want this endpoint to be redirected to /login page, as that probably complicates things.

Do you mean being able to add a REST service inside xwiki?

Also note that any wiki page can be an endpoint too since it can be accessed with a URL and it can contain a script to return whatever you need it to return and without the UI. See the /get/ action at https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Architecture/URL%20Architecture/Standard%20URL%20Format/#HType:bin

Then there are various other ways. For example if you want a custom URL, then you can introduce a new URL type (like /slack/) by implementing a Resource Reference Handler (see https://extensions.xwiki.org/xwiki/bin/view/Extension/Resource%20API#HAddinganewResourceTypeHandler) but that’s a bit more involved and requires java coding.

Yet another option (simpler) if you really want a custom URL and not use the /get/ one, is to configure the rewrite Servlet filter to forward https://snawaz-wiki.com/slack/consume-events to the /get/ URL. See an example here: https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/ShortURLs/#HUrlRewriteFilter

Hope it helps

1 Like

Feels like a Resource Reference Handler (see details in @vmassol’s message). Each Resource Reference Handler is dealing with its access control.

1 Like