A couple of weeks ago I wanted to pickup xPages again during my free time. So I created a little app and all worked well. But then for some reason I wanted to add Rest controls again ( as I did a couple of months ago ). This time I wanted to start of easy. First re-explore the workings again and eventually add a java backend to it.
This.. got a little out of hand ;). Instead of creating 1 simple API bean that handles a single type of entrypoint I decided to create a complete framework so that 1 rest control could be used to handle multiple endpoints. I’ve just added the project to github. The framework could do the following
- Finds out by itself (using config docs ) depending on the url it was triggered on what class ( ‘servlet’) to load
- Load the datastore for it ( IDataService ).
- Parses the input.
- Depending on the method type ( GET, PUT, POST, DELETE ) validates the input and executes the correct methods
- Sets the correct response code and returns data if needed ( with delete/put no data is returned
The great thing about this framework is that also contains simple validation. The framework should not be used in production at the moment but should be used as a bunch of code that shows how you COULD implement a REST API. It’s far from complete ( contains bugs… )
I will blog about the framework in the coming days to explain how it works and how you can modify it to adapt it to your own needs.