Search in sources :

Example 1 with Router

use of act.route.Router 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);
    }
}
Also used : AppConfig(act.conf.AppConfig) Router(act.route.Router) NamedPort(act.app.util.NamedPort)

Example 2 with Router

use of act.route.Router in project actframework by actframework.

the class App method initRouters.

private void initRouters() {
    router = new Router(this);
    moreRouters = new HashMap<>();
    List<NamedPort> ports = config().namedPorts();
    for (NamedPort port : ports) {
        moreRouters.put(port, new Router(this, port.name()));
    }
    if (config.cliOverHttp()) {
        NamedPort cliOverHttp = new NamedPort(AppConfig.PORT_CLI_OVER_HTTP, config.cliOverHttpPort());
        moreRouters.put(cliOverHttp, new Router(this, AppConfig.PORT_CLI_OVER_HTTP));
    }
}
Also used : Router(act.route.Router) NamedPort(act.app.util.NamedPort)

Example 3 with Router

use of act.route.Router in project actframework by actframework.

the class App method loadBuiltInRoutes.

private void loadBuiltInRoutes() {
    router().addMapping(GET, "/asset/", new ResourceGetter("asset"), RouteSource.BUILD_IN);
    router().addMapping(GET, "/~/asset/", new ResourceGetter("asset/~act"), RouteSource.BUILD_IN);
    router().addMapping(GET, "/webjars/", new ResourceGetter("META-INF/resources/webjars"), RouteSource.BUILD_IN);
    router().addContext("act.", "/~");
    if (config.cliOverHttp()) {
        Router router = router(AppConfig.PORT_CLI_OVER_HTTP);
        router.addMapping(GET, "/asset/", new ResourceGetter("asset"), RouteSource.BUILD_IN);
    }
    SecureTicketCodec secureTicketCodec = config.secureTicketCodec();
    SecureTicketHandler secureTicketHandler = new SecureTicketHandler(secureTicketCodec);
    router().addMapping(GET, "/~/ticket", secureTicketHandler);
}
Also used : SecureTicketHandler(act.ws.SecureTicketHandler) SecureTicketCodec(act.ws.SecureTicketCodec) Router(act.route.Router) ResourceGetter(act.handler.builtin.ResourceGetter)

Example 4 with Router

use of act.route.Router in project actframework by actframework.

the class App method loadRoutes.

private void loadRoutes() {
    loadBuiltInRoutes();
    logger.debug("loading app routing table: %s ...", appBase.getPath());
    Map<String, List<File>> routes;
    if (Act.isProd()) {
        routes = RuntimeDirs.routes(this);
    } else {
        routes = layout().routeTables(base());
    }
    for (Map.Entry<String, List<File>> entry : routes.entrySet()) {
        String npName = entry.getKey();
        List<File> routesFileList = entry.getValue();
        Router router = S.eq(NamedPort.DEFAULT, npName) ? this.router : this.router(npName);
        for (File route : routesFileList) {
            if (route.exists() && route.canRead() && route.isFile()) {
                List<String> lines = IO.readLines(route);
                new RouteTableRouterBuilder(lines).build(router);
            }
        }
    }
}
Also used : Router(act.route.Router) RouteTableRouterBuilder(act.route.RouteTableRouterBuilder) File(java.io.File)

Aggregations

Router (act.route.Router)4 NamedPort (act.app.util.NamedPort)2 AppConfig (act.conf.AppConfig)1 ResourceGetter (act.handler.builtin.ResourceGetter)1 RouteTableRouterBuilder (act.route.RouteTableRouterBuilder)1 SecureTicketCodec (act.ws.SecureTicketCodec)1 SecureTicketHandler (act.ws.SecureTicketHandler)1 File (java.io.File)1