當前位置: 首頁>>代碼示例>>Java>>正文


Java StaticHandler類代碼示例

本文整理匯總了Java中io.vertx.ext.web.handler.StaticHandler的典型用法代碼示例。如果您正苦於以下問題:Java StaticHandler類的具體用法?Java StaticHandler怎麽用?Java StaticHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StaticHandler類屬於io.vertx.ext.web.handler包,在下文中一共展示了StaticHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: start

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
@Override
public void start() throws Exception {
	Router router = Router.router(vertx);
	int serverPort = Config.getIntValue("serverPort");
	
	router.route().handler(BodyHandler.create().setUploadsDirectory("files"));
	router.route().handler(CookieHandler.create());
	router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
	Routing.route(router, "com.planb.restful");
	
	router.route().handler(StaticHandler.create());
	new Parser().start();
	
	Log.info("Server Started At : " + serverPort);
	vertx.createHttpServer().requestHandler(router::accept).listen(serverPort);
}
 
開發者ID:JoMingyu,項目名稱:Bobsim-Server,代碼行數:17,代碼來源:MainVerticle.java

示例2: start

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
@Override
public void start() throws Exception {
	Router router = Router.router(vertx);
	int serverPort = Config.getIntValue("serverPort");
	
	router.route().handler(BodyHandler.create().setUploadsDirectory("files"));
	router.route().handler(CookieHandler.create());
	router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
	router.route().handler(CORSHandler.create());
	router.route().handler(LogHandler.create());
	Routing.route(router, "com.planb.restful");
	
	router.route().handler(StaticHandler.create());
	
	Log.info("Server Started At : " + serverPort);
	vertx.createHttpServer().requestHandler(router::accept).listen(serverPort);
}
 
開發者ID:JoMingyu,項目名稱:Server-Quickstart-Vert.x,代碼行數:18,代碼來源:MainVerticle.java

示例3: start

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
@Override
public void start() {

    // Create a router object for web ui
    Router routerWeb = Router.router(vertx);

    // Bind new web ui
    routerWeb.route("/dfa/*").handler(StaticHandler.create("dfa").setCachingEnabled(false));
    // Bind api doc
    routerWeb.route("/api/*").handler(StaticHandler.create("apidoc").setCachingEnabled(true));
    // Bind landing page
    routerWeb.route("/*").handler(StaticHandler.create("landing").setCachingEnabled(true));

    // Create the HTTP server to serve the web ui
    vertx.createHttpServer().requestHandler(routerWeb::accept)
            .listen(config().getInteger("http.port.df.processor", 8000));

    try {
        LOG.info("DataFibers Welcome You @ http://" + InetAddress.getLocalHost().getHostAddress() + ":" +
                config().getInteger("http.port.df.processor", 8000));
    } catch (UnknownHostException e) {
        LOG.error(DFAPIMessage.logResponseMessage(9019,
                "NetworkHostException - "  + e.getCause()));
    }
}
 
開發者ID:datafibers-community,項目名稱:df_data_service,代碼行數:26,代碼來源:DFWebUI.java

示例4: start

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
public void start() throws Exception {
     Router router = Router.router(vertx);

     router.route().handler(BodyHandler.create().setUploadsDirectory("upload-files"));
     router.route().handler(CookieHandler.create());
     router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)).setNagHttps(false));
     router.route().handler(RequestSecurePreprocessor.create());
     RouteRegister.registerRouters(router, "com.dms.secure", "com.dms.api", "com.dms.templates");
     router.route("/js/*").handler(StaticHandler.create().setCachingEnabled(false).setWebRoot("WEB-INF/js/"));
     
     /*
      * @see com.dms.planb.support .TableDropper
*/
     HttpServerOptions httpOpts = new HttpServerOptions();
     /*System.out.println(SecureConfig.get("SSL_PATH"));
     System.out.println(SecureConfig.get("SSL"));
     httpOpts.setSsl(true)
             .setKeyStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")))
             .setTrustStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")));
     */
     vertx.createHttpServer(httpOpts).requestHandler(router::accept).listen(Integer.parseInt(SecureConfig.get("SERVER_PORT")));
 }
 
開發者ID:DSM-DMS,項目名稱:DMS,代碼行數:23,代碼來源:DmsVerticle.java

示例5: initStaticResourceHandler

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
private void initStaticResourceHandler() {
    StaticHandler staticHandler = StaticHandler.create();
    if (nonNull(System.getProperty("domino.webroot.location"))) {
        staticHandler.setAllowRootFileSystemAccess(true);
        staticHandler.setWebRoot(systemWebRoot());
    } else {
        staticHandler.setWebRoot(webroot);
    }

    router.route("/").order(Integer.MAX_VALUE - 2)
            .handler(this::serveIndexPage);

    router.route("/static/*").order(Integer.MAX_VALUE - 1)
            .handler(staticHandler)
            .failureHandler(this::serveResource);

    router.route("/*").order(Integer.MAX_VALUE)
            .handler(this::serveResource);

}
 
開發者ID:GwtDomino,項目名稱:domino,代碼行數:21,代碼來源:DominoLoader.java

示例6: start

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
public void start() throws Exception {
		Router router = Router.router(vertx);
		int serverPort = Config.getIntValue("serverPort");
		
		router.route().handler(BodyHandler.create().setUploadsDirectory("upload-files"));
		router.route().handler(CookieHandler.create());
		router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
		router.route().handler(CORSHandler.create());
		router.route().handler(LogHandler.create());
		
		Routing.route(router, "com.planb.restful");

		router.route().handler(StaticHandler.create());

//		new ParserThread().start();

		Log.info("Server Started");
		vertx.createHttpServer().requestHandler(router::accept).listen(serverPort);
	}
 
開發者ID:JoMingyu,項目名稱:Daejeon-People,代碼行數:20,代碼來源:CoreVerticle.java

示例7: addStaticFileHandlers

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
static void addStaticFileHandlers(Router router) {

        router.get(Uris.resourcesUri + "/*").handler(
            StaticHandler
                .create(
                    "/" + module.require(ServerConfig.class).getUploadDir()
                )
                .setDirectoryListing(true)
        );

        router.get(Uris.publicUri + "/*").handler(
            StaticHandler
                .create(
                    "/" + module.require(ServerConfig.class).getPublicDir()
                )
                .setDirectoryListing(true)
        );
    }
 
開發者ID:codefacts,項目名稱:Elastic-Components,代碼行數:19,代碼來源:TrackerServer.java

示例8: init

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
@Override
public void init(CoreContext core) {
    router = Router.router(core.vertx());
    router.route().handler(BodyHandler.create());
    RestHelper.addHeaders(router, settings.get().isSecure());

    // enable routing for static resources.
    if (regex != null && path != null) {
        router.routeWithRegex(regex).handler(StaticHandler.create()
                //.setCachingEnabled(false) -- set in HttpOptions.
                .setWebRoot(path));
    }

    router.route().handler(this::packet);
    handler.init(core);
    this.core = core;
}
 
開發者ID:codingchili,項目名稱:chili-core,代碼行數:18,代碼來源:RestListener.java

示例9: mainRouter

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
@Bean
public Router mainRouter() {
    Router router = Router.router(vertx);

    Path jbakeryHome = Paths.get(jbakeryHomeProp);

    router.route().handler(BodyHandler.create().setBodyLimit(50 * MB));
    router.route().handler(LoggerHandler.create());
    router.route().handler(ResponseTimeHandler.create());

    router.mountSubRouter(PREFIX, jbakery(Vertx.vertx()));

    router.route().handler(StaticHandler.create("output")
            .setIndexPage("index.html")
            .setCachingEnabled(false));

    return router;
}
 
開發者ID:netdava,項目名稱:jbakery,代碼行數:19,代碼來源:Routers.java

示例10: jbakery

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
public Router jbakery(Vertx vertx) {
    Router router = Router.router(vertx);

    Path jbakeryHome = Paths.get(jbakeryHomeProp);

    router.route("/static/*")
            .handler(StaticHandler.create()
                    .setAllowRootFileSystemAccess(true)
                    .setWebRoot(jbakeryHome.resolve("webroot").toString())
                    .setIndexPage("index.html")
                    .setCachingEnabled(false));

    router.route().handler(TemplateHandler.create(thymeleafTemplateEngine, "", "text/html"));

    return router;
}
 
開發者ID:netdava,項目名稱:jbakery,代碼行數:17,代碼來源:Routers.java

示例11: setUpRouter

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
private void setUpRouter(Router paramRouter) {
  router = paramRouter;
  router.route().failureHandler(failureHandler);
  if (locResolver != null) {
    locResolver.getAvailableLocales().forEach(this::loadResourceBundle);
    if (locResolver.getDefaultLocale() != null) {
      loadResourceBundle(locResolver.getDefaultLocale());
    }
  }
  if (config.getAuthProvider() != null) {
    registerAnnotationProcessor(Auth.class, new AuthProcessorFactory());
  }
  new RouteFactory(router, config).createHandlers();
  new SocketFactory(router, config).createHandlers();
  new EventBusBridgeFactory(router, config).createHandlers();
  StaticHandler staticHandler;
  final String webroot = config.getWebroot();
  if (webroot != null) {
    staticHandler = StaticHandler.create(webroot);
  } else {
    staticHandler = StaticHandler.create();
  }
  router.route(config.getAssetsPath() + "/*").handler(staticHandler);
}
 
開發者ID:aesteve,項目名稱:nubes,代碼行數:25,代碼來源:VertxNubes.java

示例12: registerWithRouter

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
@Override
public void registerWithRouter(Router router) {
  StaticHandler staticHandler = StaticHandler.create();
  staticHandler.setWebRoot("META-INF/resources/webjars");
  router.route("/static/*").handler(staticHandler);

  // Disable caching so you don't need to clear cache everytime yaml changes.
  StaticHandler swaggerHandler =
      StaticHandler.create().setWebRoot("webroot/swagger").setCachingEnabled(false);
  router.route("/doc/*").handler(swaggerHandler);
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:12,代碼來源:SwaggerUI.java

示例13: start

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
@Override
public void start() throws Exception {
    Router router = Router.router(vertx);

    router.get("/prices/:name").handler(rc -> {
        String name = rc.pathParam("name");
        Double price = prices.computeIfAbsent(name, k -> (double) random.nextInt(50));
        rc.response().end(new JsonObject().put("name", name).put("price", price).encodePrettily());
    });

    router.route().handler(BodyHandler.create());
    router.post("/prices").handler(rc -> {
        if (slow) {
            vertx.setTimer(5000, l -> computeResponse(rc));
        } else {
            computeResponse(rc);
        }
    });

    router.get("/health").handler(rc -> rc.response().end("OK"));

    router.get("/toggle").handler(rc -> {
        slow = ! slow;
        rc.response().end((slow ? "Slow" : "Normal") + " mode enabled");
    });

    router.get("/assets*").handler(StaticHandler.create());

    vertx.createHttpServer()
        .requestHandler(router::accept)
        .listen(8080);
}
 
開發者ID:cescoffier,項目名稱:vertx-chtijug-2017,代碼行數:33,代碼來源:PricerVerticle.java

示例14: mountSubRouters

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
/**
 * 掛載所有子路由
 */
private void mountSubRouters() {
    //請求體解析
    mainRouter.route().handler(BodyHandler.create());
    //靜態資源路由
    mainRouter.get("/").handler(ctx -> ctx.reroute("/static/index.html"));
    mainRouter.get("/favicon.ico").handler(this::getLogo);
    mainRouter.get("/README.md").handler(this::getReadme);
    mainRouter.get("/static/page/sys/img/*").handler(this::getReadmeImg);
    mainRouter.get("/MP_verify_*").handler(this::getWechatVerify);
    mainRouter.get("/static/*").handler(StaticHandler.create().setWebRoot("static"));
    //授權服務的子路由
    mainRouter.mountSubRouter("/oauth/wx", factory.create(WECHAT_OAUTH));
    mainRouter.mountSubRouter("/oauth/zfb", factory.create(ALIPAY_OAUTH));//TODO 支付寶授權
    //支付服務子路由
    mainRouter.mountSubRouter("/pay/wx", factory.create(WECHAT_PAY));
    mainRouter.mountSubRouter("/pay/zfb", factory.create(ALIPAY_PAY));
    //消息發送服務子路由
    mainRouter.mountSubRouter("/msg/wx", factory.create(WECHAT_MSG));
    mainRouter.mountSubRouter("/msg/zfb", factory.create(ALIPAY_MSG));
    //JsTicket和AccessTOken服務子路由
    mainRouter.mountSubRouter("/tk/wx", factory.create(WECHAT_TOKEN));
    //登錄BMS的子路由
    mainRouter.mountSubRouter("/bms/login", factory.create(BMS_LOGIN));
    //公眾號配置子路由
    mainRouter.mountSubRouter("/bms/offAcc", factory.create(BMS_ACCOUNT));
    //支付配置子路由
    mainRouter.mountSubRouter("/bms/pay", factory.create(BMS_PAY));
}
 
開發者ID:Leibnizhu,項目名稱:AlipayWechatPlatform,代碼行數:32,代碼來源:MainVerticle.java

示例15: start

import io.vertx.ext.web.handler.StaticHandler; //導入依賴的package包/類
@Override
public void start() throws Exception {

    JsonObject config = config();
    JsonArray urls = config.getJsonArray(CommonConstants.HE_RSS_URL_LIST_ENV);
    urls.iterator().forEachRemaining(o -> {
        String url = (String) o;
        HEEndpointModel model = new HEEndpointModel();
        String label = stripAndFormatSuffix(url);
        model.setLabel(label);
        model.setUrl(url);
        model.setPollingPeriod(30000);
        model.setActive(false);
        endpoints.put(label, model);
    });

    Router router = Router.router(vertx);

    HealthCheckHandler healthCheckHandler = HealthCheckHandler.create(vertx).register("server-online",
            fut -> fut.complete(online ? Status.OK() : Status.KO()));

    router.get("/api/health/readiness").handler(rc -> rc.response().end(CommonConstants.OK));
    router.get("/api/health/liveness").handler(healthCheckHandler);
    router.get("/api/get/count/:term").handler(this::getIncidentCountsForType);
    router.get("/api/get/count/:term/:id").handler(this::getIncidentCountsForTypeWithId);
    router.get("/api/get/detail/:term/:id").handler(this::getIncidentDetailsById);
    router.get("/api/config/endpoint/all").handler(this::getEndpointStatus);
    router.get("/api/config/endpoint/:label").handler(this::getEndpointStatusById);
    router.get("/*").handler(StaticHandler.create());

    router.post("/api/config/endpoint/:label/:state").handler(this::setEndpointStatusById);

    HttpServer server = vertx.createHttpServer().requestHandler(router::accept)
            .listen(config().getInteger("http.port", 8080), ar -> {
                online = ar.succeeded();
            });
}
 
開發者ID:benemon,項目名稱:he-rss-poll,代碼行數:38,代碼來源:UIServiceVerticle.java


注:本文中的io.vertx.ext.web.handler.StaticHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。