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


Java BodyHandler類代碼示例

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


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

示例1: start

import io.vertx.ext.web.handler.BodyHandler; //導入依賴的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.BodyHandler; //導入依賴的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.BodyHandler; //導入依賴的package包/類
@Override
public void start() throws Exception {
    Router router = Router.router(vertx);

    router.get("/shopping").handler(this::getList);
    router.route().handler(BodyHandler.create());
    router.post("/shopping").handler(this::addToList);
    router.delete("/shopping/:name").handler(this::deleteFromList);

    ServiceDiscovery.create(vertx, discovery -> {
        RedisDataSource.getRedisClient(discovery, rec -> rec.getName().equals("redis"), ar -> {
            redis = ar.result();
            vertx.createHttpServer()
                .requestHandler(router::accept)
                .listen(8080);
        });
    });
}
 
開發者ID:cescoffier,項目名稱:vertx-chtijug-2017,代碼行數:19,代碼來源:MyShoppingVerticle.java

示例4: startHttpServer

import io.vertx.ext.web.handler.BodyHandler; //導入依賴的package包/類
private Future<Void> startHttpServer() {
  Future<Void> future = Future.future();
  HttpServer server = vertx.createHttpServer();   // <1>

  Router router = Router.router(vertx);   // <2>
  router.get("/").handler(this::indexHandler);
  router.get("/wiki/:page").handler(this::pageRenderingHandler); // <3>
  router.post().handler(BodyHandler.create());  // <4>
  router.post("/save").handler(this::pageUpdateHandler);
  router.post("/create").handler(this::pageCreateHandler);
  router.post("/delete").handler(this::pageDeletionHandler);

  server
    .requestHandler(router::accept)   // <5>
    .listen(8080, ar -> {   // <6>
      if (ar.succeeded()) {
        LOGGER.info("HTTP server running on port 8080");
        future.complete();
      } else {
        LOGGER.error("Could not start a HTTP server", ar.cause());
        future.fail(ar.cause());
      }
    });

  return future;
}
 
開發者ID:vert-x3,項目名稱:vertx-guide-for-java-devs,代碼行數:27,代碼來源:MainVerticle.java

示例5: start

import io.vertx.ext.web.handler.BodyHandler; //導入依賴的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

示例6: start

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

    Router router = Router.router(vertx);
    router.get("/").handler(rc -> rc.response().end("hello "));
    router.get("/shopping").handler(this::getList);
    router.post().handler(BodyHandler.create());
    router.post("/shopping").handler(this::addToList);
    router.delete("/shopping/:name").handler(this::removeFromList);

    ServiceDiscovery.create(vertx, discovery -> {
        RedisDataSource.getRedisClient(discovery, svc -> svc.getName().equals("redis"), ar -> {
            if (ar.failed()) {
                System.out.println("D'oh");
            } else {
                redis = ar.result();
                vertx.createHttpServer()
                    .requestHandler(router::accept)
                    .listen(8080);
            }
        });
    });


}
 
開發者ID:cescoffier,項目名稱:vertx-kubernetes-live-coding-devoxx-ma,代碼行數:26,代碼來源:ShoppingBackendVerticle.java

示例7: start

import io.vertx.ext.web.handler.BodyHandler; //導入依賴的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

示例8: start

import io.vertx.ext.web.handler.BodyHandler; //導入依賴的package包/類
@Override
public void start() {
    Router router = Router.router(vertx);
    router.get("/").handler(rc -> rc.response().end("Hello Austin"));
    router.get("/shopping").handler(this::getList);
    router.post().handler(BodyHandler.create());
    router.post("/shopping").handler(this::addToList);
    router.delete("/shopping/:name").handler(this::deleteFromList);

    ServiceDiscovery.create(vertx, discovery -> {
        RedisDataSource.getRedisClient(discovery, svc -> svc.getName().equals("redis"), ar -> {
            if (ar.failed()) {
                System.out.println("D'oh");
            } else {
                redis = ar.result();
                vertx.createHttpServer()
                    .requestHandler(router::accept)
                    .listen(8080);
            }
        });
    });

}
 
開發者ID:cescoffier,項目名稱:vertx-reactive-summit-2017,代碼行數:24,代碼來源:ShoppingBackendVerticle.java

示例9: start

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

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

    bootstrap.getInjector().getInstance(ApplicationVertxRoutes.class).init(router, vertx);

    httpServer = vertx.createHttpServer();
    httpServer.requestHandler(router::accept).listen(getPort(), res -> {
        if (res.succeeded()) {
            log.info("Server is now listening. Thread:" + Thread.currentThread());
        } else {
            log.info("Failed to bind. Thread:" + Thread.currentThread(), res.cause());
        }
    });

}
 
開發者ID:kuangcao,項目名稱:ninja-vertx-standalone,代碼行數:20,代碼來源:NinjaVerticle.java

示例10: addMediaFileHandlers

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

        router.post(upload("/*"))
            .handler(BodyHandler.create());

        router.post(upload("/*"))
            .handler(reqHanlder(
                new FileUploadRequestHandlerImpl(
                    vertx,
                    module.require(RequestProcessingErrorHandler.class),
                    ImmutableMap.of(
                        upload(androidTrackersPicturesUri), module.require(ServerConfig.class).getUploadDir() + "/android-trackers/pictures",
                        upload(outletsPicturesUri), module.require(ServerConfig.class).getUploadDir() + "/outlets/pictures"
                    ),
                    module.require(ServerConfig.class).getUploadDir(),
                    Uris.resourcesUri
                )
            ));
    }
 
開發者ID:codefacts,項目名稱:Elastic-Components,代碼行數:20,代碼來源:TrackerServer.java

示例11: addInterceptors

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

        router.post("/api/*").handler(BodyHandler.create());
        router.put("/api/*").handler(BodyHandler.create());
        router.patch("/api/*").handler(BodyHandler.create());
        router.delete("/api/*").handler(BodyHandler.create());

        router.route().handler(reqHanlder(
            ctx -> {
                ctx.response().putHeader("Access-Control-Allow-Origin", "*");
                ctx.response().putHeader("Access-Control-Allow-Methods", "GET, PUT, PATCH, POST, DELETE, HEAD");
                ctx.response().putHeader("Access-Control-Allow-Headers", "*");
                ctx.response().putHeader("Access-Control-Max-Age", "86400");
                ctx.next();
            }
        ));

        router.route(api("/*")).handler(reqHanlder(
            module.require(AuthInterceptor.class)
        ));
    }
 
開發者ID:codefacts,項目名稱:Elastic-Components,代碼行數:22,代碼來源:TrackerServer.java

示例12: createRouter

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

        final HttpClient httpClient = vertx.createHttpClient(
            new HttpClientOptions()
                .setDefaultHost(targetHost)
                .setDefaultPort(targetPort)
        );

        final BodyHandler bodyHandler = BodyHandler.create().setBodyLimit(10 * 1024 * 1024);

        router.post(uri).handler(bodyHandler);
        router.post(uri).handler(postHandler(httpClient, HttpMethod.POST));

        router.put(uri).handler(bodyHandler);
        router.put(uri).handler(postHandler(httpClient, HttpMethod.PUT));

        router.patch(uri).handler(bodyHandler);
        router.patch(uri).handler(postHandler(httpClient, HttpMethod.PATCH));

        router.delete(uri).handler(bodyHandler);
        router.delete(uri).handler(postHandler(httpClient, HttpMethod.DELETE));

        router.get(uri).handler(postHandler(httpClient, HttpMethod.GET));
    }
 
開發者ID:codefacts,項目名稱:Elastic-Components,代碼行數:25,代碼來源:Proxy.java

示例13: init

import io.vertx.ext.web.handler.BodyHandler; //導入依賴的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

示例14: main

import io.vertx.ext.web.handler.BodyHandler; //導入依賴的package包/類
public static void main(String[] args) {
    long time = System.currentTimeMillis();
    Json.mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

    Vertx vertx = Vertx.vertx();

    Router router = Router.router(vertx);

    HelloResource helloResource = new HelloResource();
    router.get("/vertx/hello").produces("application/json").handler(helloResource::hello);
    router.route("/vertx/hello").method(HttpMethod.POST).handler(BodyHandler.create());
    router.post("/vertx/hello")
            .consumes("application/json")
            .handler(helloResource::createMessage);

    HttpServerOptions serverOptions = new HttpServerOptions()
            .setPort(8085);
    HttpServer server = vertx.createHttpServer(serverOptions);
    server.requestHandler(router::accept).listen();
    System.out.println("started in " + (System.currentTimeMillis() - time) + " ms");
}
 
開發者ID:cdelmas,項目名稱:microservices-perf,代碼行數:22,代碼來源:Main.java

示例15: startWebRoutes

import io.vertx.ext.web.handler.BodyHandler; //導入依賴的package包/類
protected Router startWebRoutes() {
    LOGGER.info("starting rest router");
    Router router = Router.router(getVertx());

    router.route("/*").handler(BodyHandler.create());
    router.get("/").handler(this::handleListBooks);
    router.post("/").handler(this::addBook);
    router.get("/:id").handler(this::receiveCookBook);
    router.get("/:book_id/recipe").handler(this::listRecipes);
    router.post("/:book_id/recipe").handler(this::addRecipe);
    router.get("/:book_id/recipe/:id").handler(this::receiveRecipe);
    router.put("/:book_id/recipe/:id").handler(this::updateRecipe);
    router.delete("/:book_id/recipe/:id").handler(this::deleteRecipe);
    
    return router;
}
 
開發者ID:ANierbeck,項目名稱:Karaf-Vertx,代碼行數:17,代碼來源:CookBookServiceVertcl.java


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