diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index e075c1e..8d3e878 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -72,6 +72,8 @@ public class AppProperties { private Boolean install_transitive_ig_dependencies = true; private Map implementationGuides = null; + private String staticLocation = null; + private Boolean lastn_enabled = false; private boolean store_resource_in_lucene_index_enabled = false; private NormalizedQuantitySearchLevel normalized_quantity_search_level = NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_SEARCH_NOT_SUPPORTED; @@ -89,6 +91,16 @@ public class AppProperties { return custom_interceptor_classes; } + + public String getStaticLocation() { + return staticLocation; + } + + public void setStaticLocation(String staticLocation) { + this.staticLocation = staticLocation; + } + + public Boolean getOpenapi_enabled() { return openapi_enabled; } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/ExtraStaticFilesConfigurer.java b/src/main/java/ca/uhn/fhir/jpa/starter/ExtraStaticFilesConfigurer.java new file mode 100644 index 0000000..fce7291 --- /dev/null +++ b/src/main/java/ca/uhn/fhir/jpa/starter/ExtraStaticFilesConfigurer.java @@ -0,0 +1,22 @@ +package ca.uhn.fhir.jpa.starter; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@ConditionalOnProperty(prefix = "hapi.fhir", name = "staticLocation") +public class ExtraStaticFilesConfigurer implements WebMvcConfigurer { + + @Autowired + AppProperties appProperties; + + @Override + public void addResourceHandlers(ResourceHandlerRegistry theRegistry) { + theRegistry + .addResourceHandler("/static/**") + .addResourceLocations(appProperties.getStaticLocation()); + } +} \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index deb2bf2..f2a9269 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -52,6 +52,7 @@ spring: # hibernate.search.backend.analysis.configurer: ca.uhn.fhir.jpa.search.HapiHSearchAnalysisConfigurers$HapiElasticAnalysisConfigurer hapi: fhir: + ### This enables the swagger-ui at /fhir/swagger-ui/index.html as well as the /fhir/api-docs (see https://hapifhir.io/hapi-fhir/docs/server_plain/openapi.html) openapi_enabled: true ### This is the FHIR version. Choose between, DSTU2, DSTU3, R4 or R5 @@ -62,6 +63,8 @@ hapi: ### forces the use of the https:// protocol for the returned server address. ### alternatively, it may be set using the X-Forwarded-Proto header. # use_apache_address_strategy_https: false + ### enables the server to host content like HTML, css, etc. under the url pattern of /static/** + # staticLocation: file:/usr/somewhere/ ### enable to set the Server URL # server_address: http://hapi.fhir.org/baseR4 # defer_indexing_for_codesystems_of_size: 101