Hi Sibert,
I would create a catalog of queries in the database. I mean… a table into the database to store the SQL with a unique ID to identify the SQL instead of put 1000 lines of SQL at the code.
The ID could be a parameter from the endpoint or even the resource URI (it depends on the business rule). So you would develop in go the mechanism to select the appropriate record.
Please, Let me know if this solution makes sense.
Cheers!
Marco.