/** * Route and call the request, respecting the given timeout. * * @param app The application used while routing and executing the request * @param router The router type * @param requestBuilder The request builder * @param timeout The amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ public static Result routeAndCall(Application app, Class<? extends Router> router, RequestBuilder requestBuilder, long timeout) { try { Request request = requestBuilder.build(); Router routes = (Router) router.getClassLoader().loadClass(router.getName() + "$").getDeclaredField("MODULE$").get(null); return routes.route(request).map(handler -> invokeHandler(app.asScala(), handler, request, timeout) ).orElse(null); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
/** * Route and call the request, respecting the given timeout. * * @param app The application used while routing and executing the request * @param router The router type * @param requestBuilder The request builder * @param timeout The amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ public static Result routeAndCall(Application app, Class<? extends Router> router, RequestBuilder requestBuilder, long timeout) { try { Request request = requestBuilder.build(); Router routes = (Router) router.getClassLoader().loadClass(router.getName() + "$").getDeclaredField("MODULE$").get(null); return routes.route(request).map(handler -> invokeHandler(app.asScala(), handler, request, timeout) ).orElse(null); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
/** * Route and call the request, respecting the given timeout. * * @param app The application used while routing and executing the request * @param router The router * @param requestBuilder The request builder * @param timeout The amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ public static Result routeAndCall(Application app, Router router, RequestBuilder requestBuilder, long timeout) { try { Request request = requestBuilder.build(); return router.route(request).map(handler -> invokeHandler(app.asScala(), handler, request, timeout) ).orElse(null); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
/** * Route and call the request, respecting the given timeout. * * @param app The application used while routing and executing the request * @param router The router * @param requestBuilder The request builder * @param timeout The amount of time, in milliseconds, to wait for the body to be produced. * @return the result */ public static Result routeAndCall(Application app, Router router, RequestBuilder requestBuilder, long timeout) { try { Request request = requestBuilder.build(); return router.route(request).map(handler -> invokeHandler(app.asScala(), handler, request, timeout) ).orElse(null); } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } }
@Override public Handler apply(play.api.mvc.RequestHeader req, boolean isCheck) throws Exception { Optional<Handler> handler = route(req.asJava()); if (handler.isPresent()) { return handler.get(); } else if (isCheck) { return null; } else { throw noMatch(); } } });
@Override public Handler apply(play.api.mvc.RequestHeader req, boolean isCheck) throws Exception { Optional<Handler> handler = route(req.asJava()); if (handler.isPresent()) { return handler.get(); } else if (isCheck) { return null; } else { throw noMatch(); } } });
@Override public Handler apply(play.api.mvc.RequestHeader req, boolean isCheck) throws Exception { Optional<Handler> handler = route(req.asJava()); if (handler.isPresent()) { return handler.get(); } else if (isCheck) { return null; } else { throw noMatch(); } } });