本文整理汇总了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);
}
示例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);
}
示例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);
});
});
}
示例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;
}
示例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")));
}
示例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);
}
示例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);
}
});
});
}
示例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());
}
});
}
示例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
)
));
}
示例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)
));
}
示例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));
}
示例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;
}
示例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");
}
示例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;
}