Prevent retrieval of Sagan metadata on startup

This commit makes sure that sagan metadata are only requested on first
use and when the cache infrastructure is active.

Closes gh-278
This commit is contained in:
Stephane Nicoll 2016-11-03 16:00:24 +01:00
parent 99ae293f36
commit e3112811b7

View File

@ -16,7 +16,6 @@
package io.spring.initializr.web.project
import javax.annotation.PostConstruct
import javax.servlet.http.HttpServletResponse
import io.spring.initializr.generator.InvalidProjectRequestException
@ -37,7 +36,7 @@ abstract class AbstractInitializrController {
protected final InitializrMetadataProvider metadataProvider
private final GroovyTemplate groovyTemplate
private boolean forceSsl
private Boolean forceSsl
protected AbstractInitializrController(InitializrMetadataProvider metadataProvider,
GroovyTemplate groovyTemplate) {
@ -45,9 +44,12 @@ abstract class AbstractInitializrController {
this.groovyTemplate = groovyTemplate
}
@PostConstruct
void initialize() {
forceSsl = metadataProvider.get().configuration.env.forceSsl
boolean isForceSsl() {
if (this.forceSsl == null) {
this.forceSsl = metadataProvider.get().configuration.env.forceSsl
}
return this.forceSsl;
}
@ExceptionHandler
@ -86,7 +88,7 @@ abstract class AbstractInitializrController {
*/
protected String generateAppUrl() {
def builder = ServletUriComponentsBuilder.fromCurrentServletMapping()
if (this.forceSsl) {
if (isForceSsl()) {
builder.scheme('https')
}
builder.build()