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

public class ErrorPage extends HttpMiddleware implements 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 Details

    • htmlTemplate

      protected String htmlTemplate
      Template of the HTML response.
    • htmlTemplatePath

      protected String htmlTemplatePath
      Template path of the HTML response.
    • statusSpecificTemplates

      protected HashMap<Integer,String> statusSpecificTemplates
      Optional status-specific templates (eg. 404 -> 404.html, 500 -> 500.html)
  • Constructor Details

    • ErrorPage

      public ErrorPage()
    • ErrorPage

      public ErrorPage(String htmlTemplateOrPath)
  • Method Details

    • install

      public RequestProcessor install(RequestProcessor next, io.datatree.Tree config)
      Specified by:
      install in class HttpMiddleware
    • setTemplate

      public ErrorPage setTemplate(int statusCode, String htmlTemplateOrPath)
    • getStatusSpecificTemplates

      public HashMap<Integer,String> getStatusSpecificTemplates()
    • setStatusSpecificTemplates

      public void setStatusSpecificTemplates(HashMap<Integer,String> statusSpecificTemplates)
    • getHtmlTemplate

      public String getHtmlTemplate()
      Returns:
      the htmlTemplate
    • setHtmlTemplate

      public void setHtmlTemplate(String htmlTemplate)
      Parameters:
      htmlTemplate - the htmlTemplate to set
    • getHtmlTemplatePath

      public String getHtmlTemplatePath()
      Returns:
      the htmlTemplatePath
    • setHtmlTemplatePath

      public void setHtmlTemplatePath(String htmlTemplatePath)
      Parameters:
      htmlTemplatePath - the htmlTemplatePath to set