Search in sources :

Example 1 with Config

use of io.kamax.mxgwd.config.Config in project mxgwd by kamax-io.

the class UndertowApp method main.

public static void main(String[] args) throws IOException {
    String cfgFile = StringUtils.defaultIfBlank(System.getenv("MXGWD_CONFIG_FILE"), "mxgwd.yaml");
    Config cfg = Value.get(YamlConfigLoader.loadFromFile(cfgFile), Config::new);
    Gateway gw = new Gateway(cfg);
    CatchAllHandler allHandler = new CatchAllHandler(gw);
    ActivePoliciesListingHandler activePolicies = new ActivePoliciesListingHandler(gw);
    Undertow server = Undertow.builder().addHttpListener(cfg.getServer().getPort(), "0.0.0.0").setHandler(Handlers.path().addExactPath("/_matrix/client/r0/policy/policies", activePolicies).addPrefixPath("/", allHandler)).build();
    server.start();
}
Also used : Config(io.kamax.mxgwd.config.Config) Gateway(io.kamax.mxgwd.model.Gateway) Undertow(io.undertow.Undertow)

Example 2 with Config

use of io.kamax.mxgwd.config.Config in project mxgwd by kamax-io.

the class YamlConfigLoader method loadFromFile.

public static Config loadFromFile(String path) throws IOException {
    Representer rep = new Representer();
    rep.getPropertyUtils().setAllowReadOnlyProperties(true);
    rep.getPropertyUtils().setSkipMissingProperties(true);
    Yaml yaml = new Yaml(new Constructor(Config.class), rep);
    Object o = yaml.load(new FileInputStream(path));
    return GsonUtil.get().fromJson(GsonUtil.get().toJson(o), Config.class);
}
Also used : Representer(org.yaml.snakeyaml.representer.Representer) Constructor(org.yaml.snakeyaml.constructor.Constructor) Config(io.kamax.mxgwd.config.Config) Yaml(org.yaml.snakeyaml.Yaml) FileInputStream(java.io.FileInputStream)

Aggregations

Config (io.kamax.mxgwd.config.Config)2 Gateway (io.kamax.mxgwd.model.Gateway)1 Undertow (io.undertow.Undertow)1 FileInputStream (java.io.FileInputStream)1 Yaml (org.yaml.snakeyaml.Yaml)1 Constructor (org.yaml.snakeyaml.constructor.Constructor)1 Representer (org.yaml.snakeyaml.representer.Representer)1