@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(); } } });
/** * Creates a new HTTP context. * * @param request the HTTP request */ public Context(Request request) { this.request = request; this.header = request._underlyingHeader(); this.id = header.id(); this.response = new Response(); this.session = new Session(JavaConversions.mapAsJavaMap(header.session().data())); this.flash = new Flash(JavaConversions.mapAsJavaMap(header.flash().data())); this.args = new HashMap<String,Object>(); this.args.putAll(JavaConversions.mapAsJavaMap(header.tags())); }
/** * Constructor only based on a header. * @param header the header from a request * * @deprecated Since 2.7.0. Use {@link #RequestImpl(play.api.mvc.Request)} instead. */ @Deprecated public RequestImpl(play.api.mvc.RequestHeader header) { super(header.withBody(null)); }
@Override public CompletionStage<Result> onClientError(RequestHeader request, int statusCode, String message) { if (!play.api.http.Status$.MODULE$.isClientError(statusCode)) { throw new IllegalArgumentException( "onClientError invoked with non client error status code " + statusCode + ": " + message); } ObjectNode result = Json.newObject(); result.put("requestId", request.asScala().id()); result.put("message", message); return CompletableFuture.completedFuture(Results.status(statusCode, error(result))); }
public Future<play.api.mvc.Result> onHandlerNotFound(play.api.mvc.RequestHeader request) { ErrorResponse er = apply(NOT_FOUND, "URI not found", apply$default$3(), Some.apply(request.path())); return Futures.successful(notFound(toJson(er)).toScala()); }
@Override public CompletionStage<Result> onClientError(RequestHeader request, int statusCode, String message) { if (!play.api.http.Status$.MODULE$.isClientError(statusCode)) { throw new IllegalArgumentException( "onClientError invoked with non client error status code " + statusCode + ": " + message); } ObjectNode result = Json.newObject(); result.put("requestId", request.asScala().id()); result.put("message", message); return CompletableFuture.completedFuture(Results.status(statusCode, error(result))); }
@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 CompletionStage<Result> onClientError(RequestHeader request, int statusCode, String message) { if (!play.api.http.Status$.MODULE$.isClientError(statusCode)) { throw new IllegalArgumentException( "onClientError invoked with non client error status code " + statusCode + ": " + message); } ObjectNode result = Json.newObject(); result.put("requestId", request.asScala().id()); result.put("message", message); return CompletableFuture.completedFuture(Results.status(statusCode, error(result))); }
/** * Constructor only based on a header. * @param header the header from a request * * @deprecated Since 2.7.0. Use {@link #RequestImpl(play.api.mvc.Request)} instead. */ @Deprecated public RequestImpl(play.api.mvc.RequestHeader header) { super(header.withBody(null)); }
@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(); } } });
/** * Invoked in dev mode when a server error occurs. * * @param request The request that triggered the error. * @param exception The exception. */ protected JsonNode devServerError(RequestHeader request, UsefulException exception) { ObjectNode exceptionJson = Json.newObject(); exceptionJson.put("title", exception.title); exceptionJson.put("description", exception.description); exceptionJson.set("stacktrace", formatDevServerErrorException(exception.cause)); ObjectNode result = Json.newObject(); result.put("id", exception.id); result.put("requestId", request.asScala().id()); result.set("exception", exceptionJson); return error(result); }
/** * Constructor only based on a header. * @param header the header from a request * * @deprecated Since 2.7.0. Use {@link #RequestImpl(play.api.mvc.Request)} instead. */ @Deprecated public RequestImpl(play.api.mvc.RequestHeader header) { super(header.withBody(null)); }
@Override public play.api.libs.streams.Accumulator<ByteString, play.api.mvc.Result> apply(play.api.mvc.RequestHeader rh) { return apply(rh.asJava()) .map(Result::asScala, Execution.trampoline()) .asScala(); }
/** * Invoked in dev mode when a server error occurs. * * @param request The request that triggered the error. * @param exception The exception. */ protected JsonNode devServerError(RequestHeader request, UsefulException exception) { ObjectNode exceptionJson = Json.newObject(); exceptionJson.put("title", exception.title); exceptionJson.put("description", exception.description); exceptionJson.set("stacktrace", formatDevServerErrorException(exception.cause)); ObjectNode result = Json.newObject(); result.put("id", exception.id); result.put("requestId", request.asScala().id()); result.set("exception", exceptionJson); return error(result); }
@Override public play.api.libs.streams.Accumulator<ByteString, play.api.mvc.Result> apply(play.api.mvc.RequestHeader rh) { return apply(rh.asJava()) .map(Result::asScala, Execution.trampoline()) .asScala(); }
/** * Invoked in dev mode when a server error occurs. * * @param request The request that triggered the error. * @param exception The exception. */ protected JsonNode devServerError(RequestHeader request, UsefulException exception) { ObjectNode exceptionJson = Json.newObject(); exceptionJson.put("title", exception.title); exceptionJson.put("description", exception.description); exceptionJson.set("stacktrace", formatDevServerErrorException(exception.cause)); ObjectNode result = Json.newObject(); result.put("id", exception.id); result.put("requestId", request.asScala().id()); result.set("exception", exceptionJson); return error(result); }
@Override public play.api.libs.streams.Accumulator<ByteString, play.api.mvc.Result> apply(play.api.mvc.RequestHeader rh) { return apply(rh.asJava()) .map(Result::asScala, Execution.trampoline()) .asScala(); }
@Override public HandlerForRequest handlerForRequest(RequestHeader request) { Tuple2<play.api.mvc.RequestHeader, Handler> result = underlying.handlerForRequest(request.asScala()); return new HandlerForRequest(result._1().asJava(), result._2()); } }
@Override public HandlerForRequest handlerForRequest(RequestHeader request) { Tuple2<play.api.mvc.RequestHeader, Handler> result = underlying.handlerForRequest(request.asScala()); return new HandlerForRequest(result._1().asJava(), result._2()); } }
@Override public HandlerForRequest handlerForRequest(RequestHeader request) { Tuple2<play.api.mvc.RequestHeader, Handler> result = underlying.handlerForRequest(request.asScala()); return new HandlerForRequest(result._1().asJava(), result._2()); } }