use of act.conf.AppConfig in project actframework by actframework.
the class ApiManager method load.
public void load(App app) {
LOGGER.info("start compiling API book");
Router router = app.router();
AppConfig config = app.config();
Set<Class> controllerClasses = new HashSet<>();
load(router, null, config, controllerClasses);
for (NamedPort port : app.config().namedPorts()) {
router = app.router(port);
load(router, port, config, controllerClasses);
}
if (Act.isDev()) {
exploreDescriptions(controllerClasses);
}
}
use of act.conf.AppConfig in project actframework by actframework.
the class ActionContext method applyGlobalCorsSetting.
private void applyGlobalCorsSetting() {
if (this.disableCors) {
return;
}
AppConfig conf = config();
if (!conf.corsEnabled()) {
return;
}
H.Response r = resp();
r.addHeaderIfNotAdded(ACCESS_CONTROL_ALLOW_ORIGIN, conf.corsAllowOrigin());
if (request.method() == H.Method.OPTIONS || !conf.corsOptionCheck()) {
r.addHeaderIfNotAdded(ACCESS_CONTROL_ALLOW_HEADERS, conf.corsAllowHeaders());
r.addHeaderIfNotAdded(ACCESS_CONTROL_ALLOW_CREDENTIALS, S.string(conf.corsAllowCredentials()));
r.addHeaderIfNotAdded(ACCESS_CONTROL_EXPOSE_HEADERS, conf.corsExposeHeaders());
r.addHeaderIfNotAdded(ACCESS_CONTROL_MAX_AGE, S.string(conf.corsMaxAge()));
}
}
use of act.conf.AppConfig in project actframework by actframework.
the class AppClassLoader method preloadLib.
private void preloadLib() {
final Map<String, byte[]> bytecodeIdx = new HashMap<>();
final Map<String, Properties> jarConf = new HashMap<>();
final $.Function<String, Boolean> ignoredClassNames = app().config().appClassTester().negate();
Jars.F.JarEntryVisitor classNameIndexBuilder = Jars.F.classNameIndexBuilder(bytecodeIdx, ignoredClassNames);
Jars.F.JarEntryVisitor confIndexBuilder = Jars.F.appConfigFileIndexBuilder(jarConf);
List<File> jars = FullStackAppBootstrapClassLoader.jars(AppClassLoader.class.getClassLoader());
for (File jar : jars) {
Jars.scan(jar, classNameIndexBuilder, confIndexBuilder);
}
libClsCache.putAll(bytecodeIdx);
AppConfig config = app().config();
config.loadJarProperties(jarConf);
}
use of act.conf.AppConfig in project actframework by actframework.
the class RouterTestBase method prepareClass.
@BeforeClass
public static void prepareClass() throws Exception {
AppConfig config = appConfig();
app = mock(App.class);
when(app.config()).thenReturn(config);
when(app.file(anyString())).thenAnswer(new Answer<File>() {
@Override
public File answer(InvocationOnMock invocation) throws Throwable {
String path = (String) invocation.getArguments()[0];
return new File(BASE, path);
}
});
Field f = App.class.getDeclaredField("INST");
f.setAccessible(true);
f.set(null, app);
}
use of act.conf.AppConfig in project actframework by actframework.
the class ViewManager method load.
public Template load(ActContext context) {
Template cached = context.cachedTemplate();
if (null != cached) {
return cached;
}
AppConfig config = context.config();
Template template;
String templateContent = context.templateContent();
if (S.notEmpty(templateContent)) {
template = getInlineTemplate(context, config, templateContent);
} else {
TemplatePathResolver resolver = config.templatePathResolver();
String path = resolver.resolve(context);
template = getTemplate(context, config, path);
if (null == template) {
String amendedPath = resolver.resolveWithContextMethodPath(context);
if (S.neq(amendedPath, path)) {
template = getTemplate(context, config, amendedPath);
if (null != template) {
context.templatePath(amendedPath);
}
}
}
}
return template;
}
Aggregations