diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Registration/FhirServerServiceCollectionExtensions.cs b/src/Microsoft.Health.Fhir.Shared.Api/Registration/FhirServerServiceCollectionExtensions.cs index 264c75f294..244fb6d4fe 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Registration/FhirServerServiceCollectionExtensions.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Registration/FhirServerServiceCollectionExtensions.cs @@ -43,25 +43,30 @@ public static class FhirServerServiceCollectionExtensions /// The services collection. /// An optional configuration root object. This method uses "FhirServer" section. /// An optional delegate to set properties after values have been loaded from configuration + /// An optional flag indicating wheter to register ASP.NET MVC components. /// A object. public static IFhirServerBuilder AddFhirServer( this IServiceCollection services, IConfiguration configurationRoot = null, - Action configureAction = null) + Action configureAction = null, + bool addMvc = true) { EnsureArg.IsNotNull(services, nameof(services)); services.AddOptions(); - services.AddMvc(options => - { - options.EnableEndpointRouting = false; - options.RespectBrowserAcceptHeader = true; - }) - .AddNewtonsoftJson(options => - { - options.SerializerSettings.DateParseHandling = Newtonsoft.Json.DateParseHandling.DateTimeOffset; - }) - .AddRazorRuntimeCompilation(); + if (addMvc) + { + services.AddMvc(options => + { + options.EnableEndpointRouting = false; + options.RespectBrowserAcceptHeader = true; + }) + .AddNewtonsoftJson(options => + { + options.SerializerSettings.DateParseHandling = Newtonsoft.Json.DateParseHandling.DateTimeOffset; + }) + .AddRazorRuntimeCompilation(); + } var fhirServerConfiguration = new FhirServerConfiguration();