/** * Responsible for logging server errors. * <p> * The base implementation uses a SLF4J logger. If a special annotation is desired for internal server errors, you may want to use SLF4J directly with the Marker API to distinguish server errors from application errors. * <p> * This can also be overridden to add additional logging information, eg. the id of the authenticated user. * * @param request The request that triggered the server error. * @param usefulException The server error. */ protected void logServerError(RequestHeader request, UsefulException usefulException) { logger.error(String.format("\n\n! @%s - Internal server error, for (%s) [%s] ->\n", usefulException.id, request.method(), request.uri()), usefulException ); }
/** * Responsible for logging server errors. * <p> * The base implementation uses a SLF4J logger. If a special annotation is desired for internal server errors, you may want to use SLF4J directly with the Marker API to distinguish server errors from application errors. * <p> * This can also be overridden to add additional logging information, eg. the id of the authenticated user. * * @param request The request that triggered the server error. * @param usefulException The server error. */ protected void logServerError(RequestHeader request, UsefulException usefulException) { logger.error(String.format("\n\n! @%s - Internal server error, for (%s) [%s] ->\n", usefulException.id, request.method(), request.uri()), usefulException ); }
/** * Responsible for logging server errors. * <p> * The base implementation uses a SLF4J logger. If a special annotation is desired for internal server errors, you may want to use SLF4J directly with the Marker API to distinguish server errors from application errors. * <p> * This can also be overridden to add additional logging information, eg. the id of the authenticated user. * * @param request The request that triggered the server error. * @param usefulException The server error. */ protected void logServerError(RequestHeader request, UsefulException usefulException) { logger.error(String.format("\n\n! @%s - Internal server error, for (%s) [%s] ->\n", usefulException.id, request.method(), request.uri()), usefulException ); }
public Optional<ServletMatching> findMatchingServlet(final Http.RequestHeader requestHeader) { final URI uri = URI.create(requestHeader.uri()); final String path = uri.getPath(); if (!path.startsWith(getContextPath())) { return Optional.empty(); } return findFirstMatchingServlet(path); }
/** * Invoked when a handler or resource is not found. * <p> * If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content. * <p> * Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template. * * @param request The request that no handler was found to handle. * @param message A message, which is not used by the default implementation. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onNotFound(RequestHeader request, String message) { if (environment.isProd()) { return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render( request.method(), request.uri(), request.asScala()))); } else { return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render( request.method(), request.uri(), Some.apply(routes.get()), request.asScala() ))); } }
/** * Invoked when a handler or resource is not found. * <p> * If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content. * <p> * Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template. * * @param request The request that no handler was found to handle. * @param message A message, which is not used by the default implementation. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onNotFound(RequestHeader request, String message) { if (environment.isProd()) { return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render( request.method(), request.uri(), request.asScala()))); } else { return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render( request.method(), request.uri(), Some.apply(routes.get()), request.asScala() ))); } }
/** * Invoked when a handler or resource is not found. * <p> * If the environment's mode is production, then returns Results.notFound (404) with the included template from `views.html.defaultpages.notFound` as the content. * <p> * Otherwise, Results.notFound (404) is rendered with {@code views.html.defaultpages.devNotFound} template. * * @param request The request that no handler was found to handle. * @param message A message, which is not used by the default implementation. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onNotFound(RequestHeader request, String message) { if (environment.isProd()) { return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.notFound.render( request.method(), request.uri(), request.asScala()))); } else { return CompletableFuture.completedFuture(Results.notFound(views.html.defaultpages.devNotFound.render( request.method(), request.uri(), Some.apply(routes.get()), request.asScala() ))); } }
/** * Invoked when a client error occurs, that is, an error in the 4xx series, which is not handled * by any of the other methods in this class already. * * The base implementation uses {@code views.html.defaultpages.badRequest} template with the given status. * * @param request The request that caused the client error. * @param statusCode The error status code. Must be greater or equal to 400, and less than 500. * @param message The error message. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onOtherClientError(RequestHeader request, int statusCode, String message) { return CompletableFuture.completedFuture(Results.status(statusCode, views.html.defaultpages.badRequest.render( request.method(), request.uri(), message, request.asScala() ))); }
/** * Responsible for logging server errors. * <p> * The base implementation uses a SLF4J Logger. If a special annotation is desired for internal server errors, you may want to use SLF4J directly with the Marker API to distinguish server errors from application errors. * <p> * This can also be overridden to add additional logging information, eg. the id of the authenticated user. * * @param request The request that triggered the server error. * @param usefulException The server error. */ protected void logServerError(RequestHeader request, UsefulException usefulException) { logger.error(String.format("\n\n! @%s - Internal server error, for (%s) [%s] ->\n", usefulException.id, request.method(), request.uri()), usefulException ); }
/** * Responsible for logging server errors. * <p> * The base implementation uses a SLF4J Logger. If a special annotation is desired for internal server errors, you may want to use SLF4J directly with the Marker API to distinguish server errors from application errors. * <p> * This can also be overridden to add additional logging information, eg. the id of the authenticated user. * * @param request The request that triggered the server error. * @param usefulException The server error. */ protected void logServerError(RequestHeader request, UsefulException usefulException) { logger.error(String.format("\n\n! @%s - Internal server error, for (%s) [%s] ->\n", usefulException.id, request.method(), request.uri()), usefulException ); }
/** * Invoked when a client error occurs, that is, an error in the 4xx series, which is not handled * by any of the other methods in this class already. * * The base implementation uses {@code views.html.defaultpages.badRequest} template with the given status. * * @param request The request that caused the client error. * @param statusCode The error status code. Must be greater or equal to 400, and less than 500. * @param message The error message. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onOtherClientError(RequestHeader request, int statusCode, String message) { return CompletableFuture.completedFuture(Results.status(statusCode, views.html.defaultpages.badRequest.render( request.method(), request.uri(), message, request.asScala() ))); }
/** * Responsible for logging server errors. * <p> * The base implementation uses a SLF4J Logger. If a special annotation is desired for internal server errors, you may want to use SLF4J directly with the Marker API to distinguish server errors from application errors. * <p> * This can also be overridden to add additional logging information, eg. the id of the authenticated user. * * @param request The request that triggered the server error. * @param usefulException The server error. */ protected void logServerError(RequestHeader request, UsefulException usefulException) { logger.error(String.format("\n\n! @%s - Internal server error, for (%s) [%s] ->\n", usefulException.id, request.method(), request.uri()), usefulException ); }
/** * Invoked when a client error occurs, that is, an error in the 4xx series, which is not handled * by any of the other methods in this class already. * * The base implementation uses {@code views.html.defaultpages.badRequest} template with the given status. * * @param request The request that caused the client error. * @param statusCode The error status code. Must be greater or equal to 400, and less than 500. * @param message The error message. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onOtherClientError(RequestHeader request, int statusCode, String message) { return CompletableFuture.completedFuture(Results.status(statusCode, views.html.defaultpages.badRequest.render( request.method(), request.uri(), message, request.asScala() ))); }
/** * Invoked when a handler or resource is not found. * * @param request The request that no handler was found to handle. * @param message A message. */ protected F.Promise<Result> onNotFound(RequestHeader request, String message){ if (environment.isProd()) { return F.Promise.<Result>pure(Results.notFound(views.html.defaultpages.notFound.render( request.method(), request.uri()))); } else { return F.Promise.<Result>pure(Results.notFound(views.html.defaultpages.devNotFound.render( request.method(), request.uri(), Some.apply(routes.get()) ))); } }
/** * Invoked when a client makes a bad request. * <p> * Returns Results.badRequest (400) with the included template from {@code views.html.defaultpages.badRequest} as the content. * * @param request The request that was bad. * @param message The error message. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onBadRequest(RequestHeader request, String message) { return CompletableFuture.completedFuture(Results.badRequest(views.html.defaultpages.badRequest.render( request.method(), request.uri(), message, request.asScala() ))); }
/** * Invoked when a client makes a bad request. * <p> * Returns Results.badRequest (400) with the included template from {@code views.html.defaultpages.badRequest} as the content. * * @param request The request that was bad. * @param message The error message. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onBadRequest(RequestHeader request, String message) { return CompletableFuture.completedFuture(Results.badRequest(views.html.defaultpages.badRequest.render( request.method(), request.uri(), message, request.asScala() ))); }
/** * Responsible for logging server errors. * * This can be overridden to add additional logging information, eg. the id of the authenticated user. * * @param request The request that triggered the server error. * @param usefulException The server error. */ protected void logServerError(RequestHeader request, UsefulException usefulException) { Logger.error(String.format("\n\n! @%s - Internal server error, for (%s) [%s] ->\n", usefulException.id, request.method(), request.uri()), usefulException ); }
/** * Invoked when a client makes a bad request. * <p> * Returns Results.badRequest (400) with the included template from {@code views.html.defaultpages.badRequest} as the content. * * @param request The request that was bad. * @param message The error message. * @return a CompletionStage containing the Result. */ protected CompletionStage<Result> onBadRequest(RequestHeader request, String message) { return CompletableFuture.completedFuture(Results.badRequest(views.html.defaultpages.badRequest.render( request.method(), request.uri(), message, request.asScala() ))); }
/** * Invoked when a client error occurs, that is, an error in the 4xx series, which is not handled * by any of the other methods in this class already. * * @param request The request that caused the client error. * @param statusCode The error status code. Must be greater or equal to 400, and less than 500. * @param message The error message. */ protected F.Promise<Result> onOtherClientError(RequestHeader request, int statusCode, String message) { return F.Promise.<Result>pure(Results.status(statusCode, views.html.defaultpages.badRequest.render( request.method(), request.uri(), message ))); }
/** * Invoked when a client makes a bad request. * * @param request The request that was bad. * @param message The error message. */ protected F.Promise<Result> onBadRequest(RequestHeader request, String message) { return F.Promise.<Result>pure(Results.badRequest(views.html.defaultpages.badRequest.render( request.method(), request.uri(), message ))); }