asp.net web api2 - Conditionally returning a custom response object to the client in Wep Api 2 -
i have web api 2 service deployed across 4 production servers. when request doesn't pass validation custom response object generated , returned client.
a rudimentary example
if (!modelstate.isvalid) { var responseobject = responsegenerator.getresponseforinvalidmodelstate(modelstate); return ok(responseobject); }
currently responsegenerator aware of environment in , generates response accordingly. example, in development it'll return lot detail in production it'll return simple failure status.
how can implement "switch" turns details on without requiring round trip database each time?
due nature of our environment using config file isn't realistic. i've considered using flag in database , caching @ application layer environmental constraints make refreshing cache on 4 servers painful.
i ended going parameter suggestion , implementing token system on end. if debug token present in request service validates against database. if it's valid , active token returns additional detail.
this allows control things our end while keeping things simple vendors , adds round trip database during debugging.
Comments
Post a Comment