Skip to content

Instantly share code, notes, and snippets.

@Gsealy
Created June 21, 2018 09:07
Show Gist options
  • Save Gsealy/02f05cc0d53327170719b749b1c185ac to your computer and use it in GitHub Desktop.
Save Gsealy/02f05cc0d53327170719b749b1c185ac to your computer and use it in GitHub Desktop.
simple verticle
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