Created
June 21, 2018 09:07
-
-
Save Gsealy/02f05cc0d53327170719b749b1c185ac to your computer and use it in GitHub Desktop.
simple verticle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cn.com.infosec.vertx.http; | |
import io.vertx.core.Future; | |
import io.vertx.core.json.JsonObject; | |
import io.vertx.reactivex.ext.web.Router; | |
import io.vertx.reactivex.ext.web.RoutingContext; | |
import cn.com.infosec.vertx.Constants; | |
import cn.com.infosec.vertx.common.RestfulApiVerticle; | |
public class ValidServiceVerticle extends RestfulApiVerticle { | |
public void start(Future<Void> startFuture) throws Exception { | |
Router router = Router.router(vertx); | |
router.post("/dovalid").handler(this::validhandler); | |
int port = config().getInteger("vertx.valid.port", Constants.ValidPORT); | |
String host = config().getString("vertx.host", "0.0.0.0"); | |
createHttpServer(router, host, port).subscribe(startFuture::complete, startFuture::fail); | |
} | |
private void validhandler(RoutingContext context) { | |
JsonObject ValidJson = new JsonObject().put("xmlarea", Constants.validtext_2); | |
vertx.eventBus().send(Constants.EVENT_BUS_VALID, ValidJson, res -> { | |
if ((boolean) res.result().body()) { | |
ok(context); | |
} else { | |
internalError(context, "valid failed"); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment