Package io.github.jirkasa.servletrouter
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetPathParam
(String paramName) Returns path parameter.boolean
Determines whether handler should be called when full request path matches or not.final void
setPathParams
(Map<String, String> pathParams) Sets path parameters.
-
Constructor Details
-
Middleware
public Middleware()
-
-
Method Details
-
setPathParams
Description copied from interface:Handler
Sets path parameters.- Specified by:
setPathParams
in interfaceHandler<Request extends javax.servlet.ServletRequest,
Response extends javax.servlet.ServletResponse> - Parameters:
pathParams
- Map of path parameters.
-
getPathParam
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 interfaceHandler<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.
-