Stirling-PDF/src/main/java/stirling/software/SPDF/config/AppConfig.java

58 lines
1.9 KiB
Java
Raw Normal View History

2023-08-13 02:15:26 +02:00
package stirling.software.SPDF.config;
2023-08-26 18:30:49 +02:00
import java.util.Arrays;
2023-08-26 13:27:52 +02:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
2023-08-13 02:15:26 +02:00
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
2023-08-26 13:27:52 +02:00
import org.springframework.core.env.Environment;
2023-08-13 02:15:26 +02:00
2023-08-26 18:30:49 +02:00
import stirling.software.SPDF.utils.PropertyConfigs;
import stirling.software.SPDF.model.ApplicationProperties;
2023-08-13 02:15:26 +02:00
@Configuration
public class AppConfig {
2023-08-26 13:27:52 +02:00
2023-08-26 18:30:49 +02:00
@Autowired
ApplicationProperties applicationProperties;
2023-08-26 13:27:52 +02:00
@Bean(name = "loginEnabled")
2023-08-13 02:15:26 +02:00
public boolean loginEnabled() {
2023-08-26 18:30:49 +02:00
System.out.println(applicationProperties.toString());
return applicationProperties.getSecurity().getEnableLogin();
2023-08-13 02:15:26 +02:00
}
2023-08-26 13:27:52 +02:00
2023-08-13 02:15:26 +02:00
@Bean(name = "appName")
public String appName() {
2023-08-26 18:30:49 +02:00
return applicationProperties.getUi().getHomeName();
2023-08-13 02:15:26 +02:00
}
@Bean(name = "appVersion")
public String appVersion() {
String version = getClass().getPackage().getImplementationVersion();
return (version != null) ? version : "0.0.0";
}
@Bean(name = "homeText")
public String homeText() {
2023-08-26 18:30:49 +02:00
return applicationProperties.getUi().getHomeDescription();
2023-08-13 02:15:26 +02:00
}
2023-08-26 18:30:49 +02:00
2023-08-13 02:15:26 +02:00
@Bean(name = "navBarText")
public String navBarText() {
2023-08-26 18:30:49 +02:00
String defaultNavBar = applicationProperties.getUi().getNavbarName() != null ? applicationProperties.getUi().getNavbarName() : applicationProperties.getUi().getHomeName();
return defaultNavBar;
2023-08-26 13:27:52 +02:00
}
@Bean(name = "rateLimit")
public boolean rateLimit() {
String appName = System.getProperty("rateLimit");
if (appName == null)
appName = System.getenv("rateLimit");
System.out.println("rateLimit=" + appName);
return (appName != null) ? Boolean.valueOf(appName) : false;
2023-08-13 02:15:26 +02:00
}
2023-08-26 13:27:52 +02:00
}