Package ninja
Interface Ninja
-
- All Known Implementing Classes:
NinjaDefault
public interface Ninja
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Result
getBadRequestResult(Context context, BadRequestException exception)
Should handle cases where the client sent strange date that led to an error.Result
getForbiddenResult(Context context)
Should handle cases where access is forbidden Should lead to a html error 403 - forbidden (and be used with the same mindset).Result
getForbiddenResult(Context context, ForbiddenRequestException exception)
Should handle cases where access is forbidden Should lead to a html error 403 - forbidden (and be used with the same mindset).Result
getInternalServerErrorResult(Context context, Exception exception, Result underlyingResult)
Should handle cases where an exception is thrown when handling a route that let to an internal server error.Result
getNotFoundResult(Context context)
Should handle cases where no route can be found for a given request.Result
getNotFoundResult(Context context, RequestNotFoundException exception)
Should handle cases where no route can be found for a given request.Result
getRenderingExceptionResult(Context context, RenderingException exception, Result underlyingResult)
Should handle cases where aRenderingException
is thrown when handling the rendering of a Result.Result
getUnauthorizedResult(Context context)
Should handle cases where access is unauthorized Should lead to a html error 401 - unauthorized (and be used with the same mindset).Result
onException(Context context, Exception exception)
This result should be used when an error occurs.void
onFrameworkShutdown()
Invoked when the server hosting Ninja is being stopped.void
onFrameworkStart()
Invoked when the framework starts.void
onRouteRequest(Context.Impl context)
When a route is requested this method is called.void
renderErrorResultAndCatchAndLogExceptions(Result result, Context context)
Should be used to render an error.
-
-
-
Method Detail
-
onRouteRequest
void onRouteRequest(Context.Impl context)
When a route is requested this method is called.
-
onException
Result onException(Context context, Exception exception)
This result should be used when an error occurs.- Parameters:
context
- The context for this requestexception
- The exception to handle. Can be used to customize error message.- Returns:
- a result you can use to render the error.
-
getRenderingExceptionResult
Result getRenderingExceptionResult(Context context, RenderingException exception, Result underlyingResult)
Should handle cases where aRenderingException
is thrown when handling the rendering of a Result. Should lead to an html error 500 -- internal server error. If no special handling is required, simply:return getInternalServerErrorResult(context, exception, underlyingResult);
-
getInternalServerErrorResult
Result getInternalServerErrorResult(Context context, Exception exception, Result underlyingResult)
Should handle cases where an exception is thrown when handling a route that let to an internal server error. Should lead to a html error 500 - internal sever error (and be used with the same mindset). Usually used by onRouteRequest(...).
-
getBadRequestResult
Result getBadRequestResult(Context context, BadRequestException exception)
Should handle cases where the client sent strange date that led to an error. Should lead to a html error 400 - bad request (and be used with the same mindset). Usually used by onRouteRequest(...).
-
getNotFoundResult
Result getNotFoundResult(Context context)
Should handle cases where no route can be found for a given request. Should lead to a html error 404 - not found (and be used with the same mindset). Usually used by onRouteRequest(...).
-
getNotFoundResult
Result getNotFoundResult(Context context, RequestNotFoundException exception)
Should handle cases where no route can be found for a given request. Should lead to a html error 404 - not found (and be used with the same mindset). Usually used by onRouteRequest(...).
-
getUnauthorizedResult
Result getUnauthorizedResult(Context context)
Should handle cases where access is unauthorized Should lead to a html error 401 - unauthorized (and be used with the same mindset). By default, WWW-Authenticate is set to None. Usually used by BasicAuthFilter for instance(...).
-
getForbiddenResult
Result getForbiddenResult(Context context)
Should handle cases where access is forbidden Should lead to a html error 403 - forbidden (and be used with the same mindset). Usually used by SecureFilter for instance(...).
-
getForbiddenResult
Result getForbiddenResult(Context context, ForbiddenRequestException exception)
Should handle cases where access is forbidden Should lead to a html error 403 - forbidden (and be used with the same mindset). Usually used by onRouteRequest(...).
-
onFrameworkStart
void onFrameworkStart()
Invoked when the framework starts. Usually inits stuff like the scheduler and so on.
-
onFrameworkShutdown
void onFrameworkShutdown()
Invoked when the server hosting Ninja is being stopped. Usually shuts down the guice injector and stopps all services.
-
renderErrorResultAndCatchAndLogExceptions
void renderErrorResultAndCatchAndLogExceptions(Result result, Context context)
Should be used to render an error. Any errors should be catched and not reported in any way to the request. For instance if your application catches a sever internal computation error use this method and its implementations to render out an error html page.
-
-