本文整理匯總了Java中io.vertx.ext.web.handler.StaticHandler.setWebRoot方法的典型用法代碼示例。如果您正苦於以下問題:Java StaticHandler.setWebRoot方法的具體用法?Java StaticHandler.setWebRoot怎麽用?Java StaticHandler.setWebRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.vertx.ext.web.handler.StaticHandler
的用法示例。
在下文中一共展示了StaticHandler.setWebRoot方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例2: 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);
}
示例3: 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);
}