Class Middleware<Request extends javax.servlet.ServletRequest,Response extends javax.servlet.ServletResponse>

java.lang.Object
io.github.jirkasa.servletrouter.Middleware<Request,Response>
Type Parameters:
Request - Type of ServletRequest.
Response - Type of ServletResponse.
All Implemented Interfaces:
Handler<Request,Response>
Direct Known Subclasses:
HttpMiddleware

public abstract class Middleware<Request extends javax.servlet.ServletRequest,Response extends javax.servlet.ServletResponse> extends Object implements Handler<Request,Response>
Represents component that is used to handle requests. Most of the time it is used performs some kind of operation or check and pass the request on for next processing. For example, it can be used to restrict some routes only to logged in users and so on.
  • Constructor Details

    • Middleware

      public Middleware()
  • Method Details

    • setPathParams

      public final void setPathParams(Map<String,String> pathParams)
      Description copied from interface: Handler
      Sets path parameters.
      Specified by:
      setPathParams in interface Handler<Request extends javax.servlet.ServletRequest,Response extends javax.servlet.ServletResponse>
      Parameters:
      pathParams - Map of path parameters.
    • getPathParam

      public String getPathParam(String paramName)
      Returns path parameter.
      Parameters:
      paramName - Name of path parameter.
      Returns:
      Value of path parameter or null.
    • matchesFullPath

      public boolean matchesFullPath()
      Description copied from interface: Handler
      Determines whether handler should be called when full request path matches or not.
      Specified by:
      matchesFullPath in interface Handler<Request extends javax.servlet.ServletRequest,Response extends javax.servlet.ServletResponse>
      Returns:
      True indicates that full request path should match path of handler. False indicates that just start of request path should match path of handler.