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


Java BodyHandler.create方法代碼示例

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


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

示例1: start

import io.vertx.ext.web.handler.BodyHandler; //導入方法依賴的package包/類
@Override
public void start(Future<Void> startFuture) throws Exception {
  Log.create(LOGGER)
          .setEvent("dispatch.deploying")
          .addData("config", config())
          .info();

  //讀取命令
  Future<Void> importCmdFuture = Future.future();
  new CmdRegister().initialize(vertx, config(), importCmdFuture);

  //Diapatch
  DispatchHandler dispatchHandler = DispatchHandler.create(vertx, config());

  Router router = Router.router(vertx);
  BodyHandler bodyHandler = BodyHandler.create();
  if (config().containsKey("bodyLimit")) {
    bodyHandler.setBodyLimit(config().getLong("bodyLimit"));
  }
  router.route().handler(bodyHandler);
  checkContainsCors(router);

  router.route().handler(BaseHandler.create());
  router.route().handler(ResponseTimeHandler.create());

  //API攔截
  router.route().handler(dispatchHandler)
          .failureHandler(FailureHandler.create());

  startHttpServer(router, startFuture);
}
 
開發者ID:edgar615,項目名稱:direwolves,代碼行數:32,代碼來源:ApiDispatchVerticle.java

示例2: addRoutes

import io.vertx.ext.web.handler.BodyHandler; //導入方法依賴的package包/類
@Override
public void addRoutes(final Router router) {

    final String pathWithTenant = String.format("/%s/:%s", CredentialsConstants.CREDENTIALS_ENDPOINT, PARAM_TENANT_ID);
    final String pathWithTenantAndDeviceId = String.format("/%s/:%s/:%s",
            CredentialsConstants.CREDENTIALS_ENDPOINT, PARAM_TENANT_ID, PARAM_DEVICE_ID);
    final String pathWithTenantAndAuthIdAndType = String.format("/%s/:%s/:%s/:%s",
            CredentialsConstants.CREDENTIALS_ENDPOINT, PARAM_TENANT_ID, PARAM_AUTH_ID, PARAM_TYPE);

    final BodyHandler bodyHandler = BodyHandler.create();
    bodyHandler.setBodyLimit(2048); // limit body size to 2kb

    // add credentials
    router.post(pathWithTenant).handler(bodyHandler);
    router.post(pathWithTenant).handler(this::extractRequiredJsonPayload);
    router.post(pathWithTenant).handler(this::addCredentials);

    // get credentials by auth-id and type
    router.get(pathWithTenantAndAuthIdAndType).handler(this::getCredentials);
    // get all credentials for a given device
    router.get(pathWithTenantAndDeviceId).handler(this::getCredentialsForDevice);

    // update credentials by auth-id and type
    router.put(pathWithTenantAndAuthIdAndType).handler(bodyHandler);
    router.put(pathWithTenantAndAuthIdAndType).handler(this::extractRequiredJsonPayload);
    router.put(pathWithTenantAndAuthIdAndType).handler(this::updateCredentials);

    // remove credentials by auth-id and type
    router.delete(pathWithTenantAndAuthIdAndType).handler(this::removeCredentials);
    // remove all credentials for a device
    router.delete(pathWithTenantAndDeviceId).handler(this::removeCredentialsForDevice);

}
 
開發者ID:eclipse,項目名稱:hono,代碼行數:34,代碼來源:CredentialsHttpEndpoint.java

示例3: addBasicRoute

import io.vertx.ext.web.handler.BodyHandler; //導入方法依賴的package包/類
private void addBasicRoute(JsonObject conf) {
	router.route().handler(CookieHandler.create());

	BodyHandler bh = BodyHandler.create();
	bh.setMergeFormAttributes(false);
	bh.setUploadsDirectory(this.upload_dir);
	// bh.setDeleteUploadedFilesOnEnd(false);
	router.route().handler(bh);

	String hasSession = conf.getString("session","true");
	if("true".equals(hasSession)){		
		SessionStore sessionStore = null;
		if (vertx.isClustered())
			sessionStore = ClusteredSessionStore.create(vertx,SessionName);
		else
			sessionStore = LocalSessionStore.create(vertx,SessionName);		
		
		SessionHandler sessionHandler = SessionHandler.create(sessionStore);
		sessionHandler.setNagHttps(false).setCookieHttpOnlyFlag(true);
		Long sessionTimeount = conf.getLong("session.timeout");
		if(sessionTimeount!=null && sessionTimeount>0)
			sessionHandler.setSessionTimeout(sessionTimeount);
		
		router.route().handler(sessionHandler);

		if(gsetting.hasAuth()  && !this.appContain.isEmpty()){
			router.route().handler(UserSessionHandler.create(authMgr.authProvider));
			
			GateAuthHandler authHandler = new GateAuthHandler(authMgr);
			router.route().handler(authHandler::handle);
			
		}
	}
	
	router.route().failureHandler(rc->{
		
		HttpServerResponse response = rc.response();
		
		if(response.ended())
			return;
		
		int statusCode = rc.statusCode() == -1 ? 500 : rc.statusCode();

           log.error("Error,status code: {}. ",statusCode);
           response.setStatusCode(statusCode).end("status code:"+statusCode);
	});

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

示例4: build

import io.vertx.ext.web.handler.BodyHandler; //導入方法依賴的package包/類
/**
 * Builds the.
 */
private void build() {

	// Initialize Vert.x if not setted
	if (vertx == null) {

		vertx = my(VertxManager.class).vertx();
	}

	// Set default port if not setted to transporter
	if (port == 0) {

		if (Boolean.valueOf(CONFIG.get(SERVER_PORT_AUTO_KEY, Boolean.FALSE))) {

			port = findForAvailablePort();
		} else {

			port = Integer.valueOf(CONFIG.get(SERVER_PORT_KEY, SERVER_PORT_DEFAULT));
		}
	}
	httpServerOptions.setPort(port);

	// Prepare SSL if available
	if (!httpServerOptions.isSsl() && Boolean.valueOf(CONFIG.get(SSL_ENABLE, Boolean.FALSE))) {

		httpServerOptions.setSsl(true).setKeyStoreOptions(new JksOptions().setPath(CONFIG.get(SSL_KEYSTORE_KEY, SSL_KEYSTORE_PATH))
				.setPassword(CONFIG.get(SSL_KEYSTORE_PASSWORD_KEY, SSL_KEYSTORE_PASSWORD)));
	}

	// Initialize Router if not setted
	if (router == null) {

		router = Router.router(vertx);
	}
	
	//Create or define the defaut route handler
	if(this.routeHandlerClass == null){
		
		this.routeHandlerClass = DefaultHandler.class;
	}

	// Create default Handler to handle file uploads and body
	if(this.bodyHandler == null){
		
		this.bodyHandler = BodyHandler.create(FILE_UPLOADS_PATH);
	}
	
	if(!ignoreBodyHandler){
		
		router.route().handler(bodyHandler);
	}

	// Collect all Middleware Handlers
	handlers.forEach(h -> HandlerWrapper.prepareHandler(router, h));

	// Collect all handlers adding to router
	collectHandlers().forEach(hd -> HandlerWrapper.prepareHandler(router, hd));

	// Initialize http server if not setted
	if (httpServer == null) {

		httpServer = vertx.createHttpServer(httpServerOptions);
	}

	// Deploy this verticle on Vert.x
	vertx.deployVerticle(this);
}
 
開發者ID:jspare-projects,項目名稱:jspare-4vertx,代碼行數:70,代碼來源:Transporter.java

示例5: bodyHandler

import io.vertx.ext.web.handler.BodyHandler; //導入方法依賴的package包/類
public BodyHandler bodyHandler() {
  return BodyHandler.create();
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:4,代碼來源:SessionRouterConfig.java

示例6: bodyHandlerForTokenRequest

import io.vertx.ext.web.handler.BodyHandler; //導入方法依賴的package包/類
private Handler<RoutingContext> bodyHandlerForTokenRequest() {
    return BodyHandler.create();
}
 
開發者ID:pac4j,項目名稱:vertx-pac4j,代碼行數:4,代碼來源:OAuth2ProviderMimic.java


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