Skip to content

Commit

Permalink
SHIBUI-2264
Browse files Browse the repository at this point in the history
Using deprecated class - updated to allow for proper future updates
  • Loading branch information
chasegawa committed Jun 8, 2022
1 parent e18aa9a commit 043f04b
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.internet2.tier.shibboleth.admin.ui.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
Expand All @@ -17,7 +17,7 @@
*/

@Configuration
@EnableConfigurationProperties({ResourceProperties.class})
@EnableConfigurationProperties({WebProperties.class})
public class StaticResourcesConfiguration implements WebMvcConfigurer {
static final String[] STATIC_RESOURCES = new String[]{
"/**/*.css",
Expand All @@ -36,16 +36,17 @@ public class StaticResourcesConfiguration implements WebMvcConfigurer {
};

@Autowired
private ResourceProperties resourceProperties = new ResourceProperties();
private WebProperties resourceProperties = new WebProperties();

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {

registry.addResourceHandler(STATIC_RESOURCES)
.addResourceLocations(resourceProperties.getStaticLocations())
.addResourceLocations(resourceProperties.getResources().getStaticLocations())
.setCachePeriod(10);
registry.addResourceHandler("/**")
.addResourceLocations(
Arrays.stream(resourceProperties.getStaticLocations())
Arrays.stream(resourceProperties.getResources().getStaticLocations())
.map(l -> l + "index.html")
.toArray(String[]::new)
)
Expand All @@ -59,4 +60,4 @@ protected Resource getResource(String resourcePath, Resource location) throws IO
}
);
}
}
}

0 comments on commit 043f04b

Please sign in to comment.