router.route("/login.do").handler(_event -> {
_event.request().bodyHandler(_req -> {
JsonObject job = new JsonObject();
String params[] = _req.toString().split("&");
for (String param : params) {
String keyValue[] = param.split("=");
if (keyValue[0].equals("usuario")) {
job.put("usuario", keyValue[1]);
} else if (keyValue[0].equals("senha")) {
job.put("senha", keyValue[1]);
}
}
eb.send("erp.autenticarcao", job, _resposta -> {
if (_resposta.succeeded()) {
_event.setUser((User) _resposta.result().body());
_event.next();
} else {
System.err.println(_resposta.cause());
_event.reroute("/dynamic/pageLogin.templ");
}
});
});
});
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/fd2969e9-25d7-46ab-a205-2570a4a31c9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
router.route("/")... (for the index page)router.route("/static/*")... (for the static content)router.route("/dynamic/*")... (for dynamic content)router.route("/login.do")... (and this to the route when happens the error. I posted before)
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/078728bc-0ab0-4a7b-ab14-ec06580bcf51%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/4c70874c-c7ac-4e01-bfd0-f3861f1b567e%40googlegroups.com.
SCHWERWIEGEND: Unexpected exception in route
java.lang.IllegalStateException: Request has already been read
at io.vertx.core.http.impl.HttpServerRequestImpl.checkEnded(HttpServerRequestImpl.java:426)
at io.vertx.core.http.impl.HttpServerRequestImpl.setExpectMultipart(HttpServerRequestImpl.java:322)
at io.vertx.ext.web.impl.HttpServerRequestWrapper.setExpectMultipart(HttpServerRequestWrapper.java:146)
at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.<init>(BodyHandlerImpl.java:86)
at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:50)
at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:37)
at io.vertx.ext.web.impl.RouteImpl.handleContext(RouteImpl.java:220)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:78)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:93)
at io.vertx.ext.web.handler.impl.UserSessionHandlerImpl.handle(UserSessionHandlerImpl.java:63)
at io.vertx.ext.web.handler.impl.UserSessionHandlerImpl.handle(UserSessionHandlerImpl.java:29)
at io.vertx.ext.web.impl.RouteImpl.handleContext(RouteImpl.java:220)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:78)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:93)
at io.vertx.ext.web.handler.impl.SessionHandlerImpl.lambda$handle$156(SessionHandlerImpl.java:117)
at io.vertx.ext.web.handler.impl.SessionHandlerImpl$$Lambda$135/1023898452.handle(Unknown Source)
at io.vertx.ext.web.handler.impl.SessionHandlerImpl.lambda$doGetSession$158(SessionHandlerImpl.java:142)
at io.vertx.ext.web.handler.impl.SessionHandlerImpl$$Lambda$136/969740892.handle(Unknown Source)
at io.vertx.ext.web.sstore.impl.LocalSessionStoreImpl.get(LocalSessionStoreImpl.java:55)
at io.vertx.ext.web.handler.impl.SessionHandlerImpl.doGetSession(SessionHandlerImpl.java:130)
at io.vertx.ext.web.handler.impl.SessionHandlerImpl.lambda$null$157(SessionHandlerImpl.java:137)
at io.vertx.ext.web.handler.impl.SessionHandlerImpl$$Lambda$137/442015822.handle(Unknown Source)
at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:732)
at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:703)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$3(ContextImpl.java:335)
at io.vertx.core.impl.ContextImpl$$Lambda$13/134138801.run(Unknown Source)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)SEVERE: Unexpected exception in route
java.lang.IllegalStateException: Request has already been read
server = $vertx.create_http_server()
router = VertxWeb::Router.router($vertx)
router.post("/ldclive/video_chunk")
.handler(&VertxWeb::BodyHandler.create().method(:handle))
.handler() {|c|
c.request().set_expect_multipart(true)
c.next
}.blocking_handler(chunk_proc, false)
.handler() {|c|
c.response.put_header('content-type', 'application/json').end({msg: 'Received'}.to_json)
}
router.post("/ldclive/video_chunk/finish")
.handler(&VertxWeb::BodyHandler.create().method(:handle))
.blocking_handler(finish_proc, false)
.handler() {|c|
c.response.put_header('content-type', 'application/json').end({msg: 'Received'}.to_json)
}
server.request_handler(&router.method(:accept)).listen(8080)
# require 'this'# require 'that'
is_prod = (ENV['ENVIRONMENT'] == 'production')
class_loader = java.lang.Thread.currentThread().getContextClassLoader()
# .... some db stuff
db_yml = (!is_prod ? class_loader.get_resource('database.yml').get_path : nil)
establish_db_connection(db_yml)
done_handler = Proc.new {|c|
c.response.put_header('content-type', 'application/json').end({msg: 'Received'}.to_json)
}
options = { logActivity: true }
port = 8080
if is_prod
# .... some SSL stuff
key_file = class_loader.get_resource 'ssl/my-key.pem'
crt_file = class_loader.get_resource 'ssl/my-cert.pem'
key = File.read key_file.get_path
crt = File.read crt_file.get_path
prod_options = {
'ssl' => true,
# 'useAlpn' => true,
'pemKeyCertOptions' => {
'keyValue' => Base64.strict_encode64(key),
'certValue' => Base64.strict_encode64(crt)
}
}
options.merge! prod_options
port = 443
end
server = $vertx.create_http_server(options)
router = VertxWeb::Router.router($vertx)
router.route().failure_handler() do |c|
# If -1, it means that the connection was dropped
# by the client. Safe to ignore.
if c.status_code != -1
c.response.set_status_code(c.status_code).end("Error: #{c.get('message')}")
end
end
# NOTICE HOW HIGH UP THIS IS!!! WAY UP TOP...
router.route().handler() do |c|
c.request().set_expect_multipart(true)
c.next
end
# THESE ALSO NEED TO BE WAYYY UP TOP...
router.route().handler(&VertxWeb::LoggerHandler.create().method(:handle))
router.route().handler(&VertxWeb::BodyHandler.create().method(:handle))
router.route("/my/path1").blocking_handler(&My::ChunkUtil.handle()).handler(&done_handler)
router.route("/my/path2/finish").blocking_handler(&My::TranscodeUtil.handle()).handler(&done_handler)
router.route("/ping").handler(&done_handler)
# CORS
#
allowedHeaders = Set.new
%w(Access-Control-Allow-Origin Access-Control-Allow-Method Access-Control-Allow-Credentials Content-Type).each { |h|
allowedHeaders.add? h
}
cors_origin = (is_prod ? ".*example\\.com" : ".*localhost:.*")
router.route().handler(&VertxWeb::CorsHandler.create(cors_origin)
.allowed_headers(allowedHeaders)
.allow_credentials(true)
.allowed_method(:GET)
.allowed_method(:POST)
.allowed_method(:OPTIONS)
.method(:handle)
)
eb_opts = {
'outboundPermitteds' => [
{'address' => 'video-upload-feed'}
]
}
router.route("/eventbus/*").handler(&VertxWeb::SockJSHandler.create($vertx).bridge(eb_opts).method(:handle))
server.request_handler(&router.method(:accept))
server.listen(port)
puts "Listening."
Thanks Adam! That did it. MUCH appreciated.BobN
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/bd4a538a-c764-4bda-9b64-18153f9b6f5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CA%2Bb4%2B20M9A_2dkk5BHd4UVxsxuJanA-ooDqccO90np%3DeCgcAFA%40mail.gmail.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/87393794-D315-4B03-8969-52C746AA0213%40julienviet.com.
For more options, visit https://groups.google.com/d/optout.