jackson - How to access Headers parameter while deserializing json payload? -
i'm working on legacy jersey project has wrapper class localdatetime
parameter, of used on resources *param (query, form,path)
, on attribute of json payload deserialized through jackson. of these endpoints contain header parameter denotes timezone.
the timezone captured through containerrequestfilter uses threadlocal:
public class timezonefilter implements containerrequestfilter { public static final threadlocal<zoneid> zoneid = new threadlocal<zoneid>(); @override public void filter(containerrequestcontext requestcontext, containerresponsecontext responsecontext) throws ioexception { settimezone(requestcontext); ... } }
im in process of switching on existing resources use jersey async
, there cases these resources null zoneids when getting threadlocal. in order avoid this, ive used javax.ws.rs.ext.paramconverterprovider
@provider public class mycustomparamconverterprovider implements paramconverterprovider { @context private httpheaders httpheaders; @override public <t> paramconverter<t> getconverter(class<t> rawtype, type generictype, annotation[] annotations) { //.. converting target wrapper class while using injected headers reference zone } }
this works query, form , path
. resources require json payload, how access request headers inside custom deserializer wrapper class?
Comments
Post a Comment