Hi folks,
The project I’m working on has a REST API endpoint
/api/v1/exportreport. It’s simple enough - it allows users to specify a date range and will produce a response containing data within the specified range that is then exported to a CSV file.
I’m a little confused by how the parameterisation of the endpoint has been written. By viewing the call made by the front-end code in the console of the browser I’m using, I can see that it’s calling the endpoint with these parameters
That’s all fine. However here is the
Java code in the controller that handles this request
That “parameters” map is what’s confusing me. The code is working (I’ve tested it via the front-end) but I don’t know how or where the “fromDate” and “toDate” parameters are being slotted into a Map. Is this something that Spring Boot does behind the scenes? Furthermore, do you think this is good design? I’ve not shown the code that validates the parameters contained in the Map (basically, there is a configurable list of required parameters for this endpoint, which the service checks to see if they’re present in the Map) but the contents of the Map are used to build a query that is executed using a JdbcTemplate.