java.lang.Object
com.jpro.webapi.server.ServerAPI
This class provides some basic functionality to interact with the server.
This class is experimental and may change in future versions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
addRequestHandler
(Function<Request, Response> handler) Adds a request handler to the server.abstract String
Return the version of the currently running JPro server.static ServerAPI
Returns the singleton instance of the server API.abstract void
removeRequestHandler
(Function<Request, Response> handler) Removes a request handler from the server.static void
setServerAPI
(ServerAPI serverAPI) Sets the singleton instance of the server API.
-
Constructor Details
-
ServerAPI
public ServerAPI()
-
-
Method Details
-
setServerAPI
Sets the singleton instance of the server API. This method is used internally by JPro to set the server API.- Parameters:
serverAPI
- the server API to set
-
getServerAPI
Returns the singleton instance of the server API.- Returns:
- the singleton instance of the server API
- Throws:
RuntimeException
- if the server API is not available
-
getJProVersion
Return the version of the currently running JPro server.- Returns:
- the version string
- Since:
- 2024.2.2
-
addRequestHandler
Adds a request handler to the server. If the response from the handler is empty, the next handler will be called. If no handler can handle the request, the JPro Server will handle it.- Parameters:
handler
- the function that processes requests and returns responses
-
removeRequestHandler
Removes a request handler from the server.- Parameters:
handler
- the function to be removed from handling requests
-