vendredi 10 décembre 2021

REST Design | Path and Query Params

I have a rest endpoint that has an optional query param. How and where should I handle this optional

Its an additional filter when I get my data, so basically the DB query that I need to run differ based on the this optional param.

If i add null check for this in the resource handler, and then another if else inside my service to decide what to do that looks like a dirty design. Just because say if I end up with 5 more optional params that can be used to filter same data object then what will I do.

Please help me with what's standard design pattern that i should use here. when to decide that i need a new resource and not put if/else in my existing resources. Is there a more sophisticated way to handle this then please suggest. I'm Using Kotlin and RestEasy

Aucun commentaire:

Enregistrer un commentaire