@@ -28,11 +28,12 @@ namespace UdapEd.Server.Controllers;
2828[ EnableRateLimiting ( RateLimitExtensions . Policy ) ]
2929public class FhirController : FhirBaseController < FhirController >
3030{
31- public FhirController (
31+ public FhirController (
3232 FhirClientWithUrlProvider fhirClient ,
3333 FhirClient fhirTerminologyClient ,
34- ILogger < FhirController > logger )
35- : base ( fhirClient , fhirTerminologyClient , logger )
34+ ILogger < FhirController > logger ,
35+ CustomDecompressionHandler customDecompressionHandler )
36+ : base ( fhirClient , fhirTerminologyClient , logger , customDecompressionHandler )
3637 { }
3738}
3839
@@ -44,8 +45,9 @@ public class FhirMtlsController : FhirBaseController<FhirMtlsController>
4445 public FhirMtlsController (
4546 FhirMTlsClientWithUrlProvider fhirClient ,
4647 FhirClient fhirTerminologyClient ,
47- ILogger < FhirMtlsController > logger )
48- : base ( fhirClient , fhirTerminologyClient , logger )
48+ ILogger < FhirMtlsController > logger ,
49+ CustomDecompressionHandler customDecompressionHandler )
50+ : base ( fhirClient , fhirTerminologyClient , logger , customDecompressionHandler )
4951 { }
5052}
5153
@@ -54,15 +56,18 @@ public class FhirBaseController<T> : ControllerBase
5456 private readonly FhirClient _fhirClient ;
5557 private readonly FhirClient _fhirTerminologyClient ;
5658 private readonly ILogger < T > _logger ;
59+ private readonly CustomDecompressionHandler _customDecompressionHandler ;
5760
5861 public FhirBaseController (
5962 FhirClient fhirClient ,
6063 FhirClient fhirTerminologyClient ,
61- ILogger < T > logger )
64+ ILogger < T > logger ,
65+ CustomDecompressionHandler customDecompressionHandler )
6266 {
6367 _fhirClient = fhirClient ;
6468 _fhirTerminologyClient = fhirTerminologyClient ;
6569 _logger = logger ;
70+ _customDecompressionHandler = customDecompressionHandler ;
6671 }
6772
6873 [ HttpPost ( "SearchForPatient" ) ]
@@ -331,7 +336,9 @@ public async Task<IActionResult> GetSearch([FromBody] string fullSearch)
331336 try
332337 {
333338 //Todo maybe inject in the future, so we don't exhaust underlying HttpClient
334- var fhirClient = new FhirClient ( fullSearch , new FhirClientSettings ( ) { PreferredFormat = ResourceFormat . Json } ) ;
339+ var httpClient = new HttpClient ( _customDecompressionHandler ) ;
340+ var fhirClient = new FhirClient ( fullSearch , httpClient , new FhirClientSettings ( ) { PreferredFormat = ResourceFormat . Json } ) ;
341+
335342 Console . WriteLine ( fullSearch ) ;
336343 var bundle = await fhirClient . GetAsync ( fullSearch ) ;
337344 var bundleJson = await new FhirJsonSerializer ( ) . SerializeToStringAsync ( bundle ) ;
@@ -370,7 +377,8 @@ public async Task<IActionResult> PostSearch([FromBody] SearchForm searchForm)
370377 try
371378 {
372379 //Todo maybe inject in the future, so we don't exhaust underlying HttpClient
373- var fhirClient = new FhirClient ( searchForm . Url , new FhirClientSettings ( ) { PreferredFormat = ResourceFormat . Json } ) ;
380+ var httpClient = new HttpClient ( _customDecompressionHandler ) ;
381+ var fhirClient = new FhirClient ( searchForm . Url , httpClient , new FhirClientSettings ( ) { PreferredFormat = ResourceFormat . Json } ) ;
374382 var searchParams = new SearchParams ( ) ;
375383
376384 foreach ( var pair in searchForm . FormUrlEncoded )
@@ -415,7 +423,9 @@ public async Task<IActionResult> Get([FromBody] string resourcePath)
415423 {
416424 try
417425 {
418- var fhirClient = new FhirClient ( resourcePath , new FhirClientSettings ( ) { PreferredFormat = ResourceFormat . Json } ) ;
426+ var httpClient = new HttpClient ( _customDecompressionHandler ) ;
427+ var fhirClient = new FhirClient ( resourcePath , httpClient , new FhirClientSettings ( ) { PreferredFormat = ResourceFormat . Json } ) ;
428+
419429 Console . WriteLine ( resourcePath ) ;
420430 var resource = await fhirClient . GetAsync ( resourcePath ) ;
421431 var resourceJson = await new FhirJsonSerializer ( ) . SerializeToStringAsync ( resource ) ;
0 commit comments