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


Java StaticHandler.create方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: enableStaticHandler

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

            // StaticHandler staticHandler = StaticHandler.create("web",
            // this.getClass().getClassLoader());
            // TODO - use classpath

            logger.info("Creating static handler.");
            StaticHandler staticHandler = StaticHandler.create(System.getProperty(WebBotConfig.FILES_WEBDESK));
            staticHandler.setCacheEntryTimeout(5);
            staticHandler.setFilesReadOnly(false);

            router.route(Config.getString(WebBotConfig.WEB_DIRECTORY)).handler(staticHandler);

        }
 
開發者ID:symphonyoss,項目名稱:helpdesk-bot,代碼行數:15,代碼來源:WebServer.java

示例5: registerEndPoints

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

	StaticHandler staticHandler = StaticHandler.create("demo");
	staticHandler.setDirectoryListing(false);
	staticHandler.setCachingEnabled(false);
	staticHandler.setIndexPage("index.html");
	route("/*").method(GET).handler(staticHandler);
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:11,代碼來源:DemoAppEndpoint.java

示例6: registerEndPoints

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

	EndpointRoute queryEndpoint = createEndpoint();
	queryEndpoint.method(POST);
	queryEndpoint.exampleRequest(graphqlExamples.createQueryRequest());
	queryEndpoint.exampleResponse(OK, graphqlExamples.createResponse(), "Basic GraphQL response.");
	queryEndpoint.description("Endpoint which accepts GraphQL queries.");
	queryEndpoint.path("/");
	queryEndpoint.blockingHandler(rc -> {
		GraphQLContext gc = new GraphQLContextImpl(rc);
		String body = gc.getBodyAsString();
		queryHandler.handleQuery(gc, body);
	}, false);

	log.info("GraphiQL is owned and developed by Facebook, Inc. - Copyright (c) 2015, Facebook, Inc. All rights reserved.");
	StaticHandler staticHandler = StaticHandler.create("graphiql");
	staticHandler.setDirectoryListing(false);
	staticHandler.setCachingEnabled(false);
	staticHandler.setIndexPage("index.html");

	// Redirect handler
	route("/browser").method(GET).handler(rc -> {
		if (rc.request().path().endsWith("/browser")) {
			rc.response().setStatusCode(302);
			rc.response().headers().set("Location", rc.request().path() + "/");
			rc.response().end();
		} else {
			rc.next();
		}
	});

	route("/browser/*").method(GET).handler(staticHandler);

}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:37,代碼來源:GraphQLEndpoint.java

示例7: addStaticHandler

import io.vertx.ext.web.handler.StaticHandler; //導入方法依賴的package包/類
public void addStaticHandler() {
	StaticHandler staticHandler = StaticHandler.create("elastichead");
	staticHandler.setDirectoryListing(false);
	staticHandler.setCachingEnabled(false);
	staticHandler.setIndexPage("index.html");
	route("/*").method(GET).handler(staticHandler);
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:8,代碼來源:ElasticsearchHeadEndpoint.java

示例8: initRoutes

import io.vertx.ext.web.handler.StaticHandler; //導入方法依賴的package包/類
private void initRoutes(JsonObject conf,HttpServer server,AppContain appContain, String indexPage) {

		if(S.isNotBlank(indexPage))
			router.route("/").handler(r->{RequestHelper.redirect(r.request(), indexPage).end();});
		
		this.addBasicRoute(conf);

		
		if(!appContain.isEmpty())
			AppRoute.addAppRoute(appContain,router);

		//如果配置了靜態文件目錄,那麽在沒有命中前麵的route path時,可以直接映射到靜態文件目錄中去
		if(webroot!=null){
			StaticHandler sta = StaticHandler.create(webroot);
			router.route().handler(sta);
		}
		
		
		server.requestHandler(router::accept);

	}
 
開發者ID:troopson,項目名稱:etagate,代碼行數:22,代碼來源:OutServerVerticle.java

示例9: UdidbServer

import io.vertx.ext.web.handler.StaticHandler; //導入方法依賴的package包/類
public UdidbServer(String[] args)
{
    // TODO process args to configure the server

    initializeLogging();

    String uiPath = System.getProperty("udidb.ui.path", "");
    boolean cors = Boolean.getBoolean("udidb.cors");

    Injector injector = Guice.createInjector(new ServerModule());

    Vertx vertx = injector.getInstance(Vertx.class);

    this.httpServer = vertx.createHttpServer(new HttpServerOptions().setWebsocketSubProtocols("wamp.2.json"));

    // WebSocket events
    this.httpServer.websocketHandler(websocket -> {
        if (!websocket.path().equals("/events")) {
            websocket.reject();
        }

        injector.getInstance(EventsSocket.class).setServerWebSocket(websocket);
    });

    Router router = Router.router(vertx);

    // static content for the UI
    StaticHandler staticHandler = StaticHandler.create();
    if (uiPath != null) {
        staticHandler.setAllowRootFileSystemAccess(true);
        staticHandler.setWebRoot(uiPath);
    }else{
        staticHandler.setWebRoot("webui");
    }
    router.route("/webui/*").handler(staticHandler);

    // API resources
    if (cors) {
        router.route().handler(CorsHandler.create("*").allowedHeader("Content-Type"));
    }

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

    DebuggeeContexts debuggeeContexts = injector.getInstance(DebuggeeContexts.class);

    router.get("/debuggeeContexts")
          .blockingHandler(noParamHandler(debuggeeContexts::getAll));
    router.post("/debuggeeContexts")
          .blockingHandler(bodyHandler(debuggeeContexts::create));
    router.options("/debuggeeContexts")
          .blockingHandler(ok());
    router.get("/debuggeeContexts/operations")
          .blockingHandler(noParamHandler(debuggeeContexts::getOperationDescriptions));
    router.post("/debuggeeContexts/globalOperation")
          .blockingHandler(bodyHandler(debuggeeContexts::createGlobalOperation));
    router.options("/debuggeeContexts/globalOperation")
          .blockingHandler(ok());
    router.get("/debuggeeContexts/:id")
          .blockingHandler(pathParamHandler("id", debuggeeContexts::get));
    router.get("/debuggeeContexts/:id/process")
          .blockingHandler(pathParamHandler("id", debuggeeContexts::getProcess));
    router.get("/debuggeeContexts/:id/process/threads")
          .blockingHandler(pathParamHandler("id", debuggeeContexts::getThreads));
    router.get("/debuggeeContexts/:id/process/threads/:threadId")
          .blockingHandler(varPathParamHandler(debuggeeContexts::getThread, "id", "threadId"));
    router.post("/debuggeeContexts/:id/process/operation")
          .blockingHandler(bodyHandler("id", debuggeeContexts::createOperation));
    router.options("/debuggeeContexts/:id/process/operation")
          .blockingHandler(ok());
    router.get("/debuggeeContexts/:id/process/operation")
          .blockingHandler(pathParamHandler("id", debuggeeContexts::getOperation));
    router.get("/debuggeeContexts/:id/process/operations")
          .blockingHandler(pathParamHandler("id", debuggeeContexts::getOperationDescriptions));

    httpServer.requestHandler(router::accept);
}
 
開發者ID:udidb,項目名稱:udidb,代碼行數:77,代碼來源:UdidbServer.java


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