Merge remote-tracking branch 'origin/master'

This commit is contained in:
FyloZ 2020-03-08 22:40:46 -04:00
commit 24ae85f56f
5 changed files with 14 additions and 2 deletions

View File

@ -11,6 +11,8 @@ public class Preferences {
public static boolean urlUsePort;
public static boolean urlUseHttps;
public static String uploadDirectory;
public static String passwordsFileName;

View File

@ -50,6 +50,7 @@ public class SpringConfiguration {
@Bean
public void setPreferences() {
Preferences.urlUsePort = creProperties.isUrlUsePort();
Preferences.urlUseHttps = creProperties.isUrlUseHttps();
Preferences.uploadDirectory = creProperties.getUploadDirectory();
Preferences.passwordsFileName = creProperties.getPasswordFile();
Preferences.logger = LoggerFactory.getLogger(ColorRecipesExplorerApplication.class);

View File

@ -13,6 +13,7 @@ public class CREProperties {
private String passwordFile;
private String uploadDirectory;
private boolean urlUseHttps;
private boolean urlUsePort;
}

View File

@ -11,6 +11,9 @@ import java.net.URISyntaxException;
public class ControllerUtils {
private static final String HTTP_SCHEME = "http";
private static final String HTTPS_SCHEME = "https";
public static String redirect(String viewName) {
return String.format("redirect:/%s", viewName);
}
@ -20,9 +23,9 @@ public class ControllerUtils {
}
public static String getUrlFromURI(URI uri) {
String scheme = uri.getScheme();
String host = uri.getHost();
int port = uri.getPort();
String scheme = getScheme();
return String.format("%s://%s:%s", scheme, host, port);
}
@ -34,7 +37,7 @@ public class ControllerUtils {
HttpServletRequest request = attributes.getRequest();
String port = ":" + (Preferences.urlUsePort ? request.getServerPort() : "");
return String.format("%s://%s%s%s", request.getScheme(), request.getServerName(), port, request.getContextPath());
return String.format("%s://%s%s%s", getScheme(), request.getServerName(), port, request.getContextPath());
}
public static String getLatestUrl() {
@ -55,4 +58,8 @@ public class ControllerUtils {
return "";
}
}
private static String getScheme() {
return Preferences.urlUseHttps ? HTTPS_SCHEME : HTTP_SCHEME;
}
}

View File

@ -16,6 +16,7 @@ server.port=9090
cre.server.upload-directory=./workdir
cre.server.password-file=passwords.txt
cre.server.url-use-port=true
cre.server.url-use-https=false
# DEFAULT MATERIAL TYPES
entities.material-types.defaults[0].name=Aucun