I have been tasked with creating a "filter" for our custom Confluence plug-in that will intercept all REST requests and forward them appropriately depending on whether or not they are valid requests. For example, if somebody makes a PUT request against a GET resource, I want to redirect them to a standard error page. We have implemented this in all of our independent REST classes, but would prefer to consolidate all this to a single class.
Community moderators have prevented the ability to post new answers.
What you are looking for is a servlet filter, not a servlet!
Both of those are available as plugin module types: https://developer.atlassian.com/confdev/confluence-plugin-guide/confluence-plugin-module-types
Ok, that sounds very promising. Thank you. I was also thinking about having a single REST class that has all the annotated paths I need, then just calling the other classes for the JSON that I will return to a request, and provide errors upon bad requests. Is that also a viable option? Thanks for replying.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also ... is this an actual module I need to download, or it simply annotating the atlassian-plugin.xml file?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, also ... Is the servlet filter class just a typical Servlet class?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, it would involve you writing a java servlet class.
This tutorial has a good example for a servlet and implements the GET method. you could implement others like POST too.
https://developer.atlassian.com/docs/common-coding-tasks/creating-an-admin-configuration-form
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.