Class ErrorPage
java.lang.Object
services.moleculer.service.MoleculerComponent
services.moleculer.service.Service
services.moleculer.web.middleware.HttpMiddleware
services.moleculer.web.middleware.ErrorPage
- All Implemented Interfaces:
services.moleculer.service.MoleculerLifecycle, HttpConstants
Custom error page (Error 404, 500, etc.) handler. Sample:
ErrorPage errors = new ErrorPage("error-default.html");
errors.setTemplate(404, "error-404.html");
errors.setTemplate(500, "error-500.html");
route.use(errors);
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringTemplate of the HTML response.protected StringTemplate path of the HTML response.Optional status-specific templates (eg. 404 -> 404.html, 500 -> 500.html)Fields inherited from class services.moleculer.service.MoleculerComponent
broker, logger, nameFields inherited from interface HttpConstants
ACCEPT, ACCEPT_ENCODING, AUTHORIZATION, CACHE_CONTROL, CHUNKED, CLOSE, CONNECT, CONNECTION, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE, CONTENT_TYPE_HTML, CONTENT_TYPE_JSON, COOKIE, DEFLATE, DELETE, ETAG, GET, GZIP, HEAD, IF_NONE_MATCH, KEEP_ALIVE, LOCATION, META_CONTENT_TYPE, META_HEADERS, META_LOCALE, META_LOCATION, META_SESSION, META_STATUS, META_TEMPLATE, NO_CACHE, OPTIONS, PATCH, POST, PROPERTY_COOKIES, PROPERTY_SESSION_ID, PROPERTY_USER, PUT, SET_COOKIE, TRACE, TRANSFER_ENCODING, WWW_AUTHENTICATE, X_FORWARDED_FOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioninstall(RequestProcessor next, io.datatree.Tree config) voidsetHtmlTemplate(String htmlTemplate) voidsetHtmlTemplatePath(String htmlTemplatePath) voidsetStatusSpecificTemplates(HashMap<Integer, String> statusSpecificTemplates) setTemplate(int statusCode, String htmlTemplateOrPath) Methods inherited from class services.moleculer.service.MoleculerComponent
getBroker, getLogger, getName, started, stopped
-
Field Details
-
htmlTemplate
Template of the HTML response. -
htmlTemplatePath
Template path of the HTML response. -
statusSpecificTemplates
-
-
Constructor Details
-
ErrorPage
public ErrorPage() -
ErrorPage
-
-
Method Details
-
install
- Specified by:
installin classHttpMiddleware
-
setTemplate
-
getStatusSpecificTemplates
-
setStatusSpecificTemplates
-
getHtmlTemplate
- Returns:
- the htmlTemplate
-
setHtmlTemplate
- Parameters:
htmlTemplate- the htmlTemplate to set
-
getHtmlTemplatePath
- Returns:
- the htmlTemplatePath
-
setHtmlTemplatePath
- Parameters:
htmlTemplatePath- the htmlTemplatePath to set
-