Module jpro.webapi

Class ServerAPI

java.lang.Object
com.jpro.webapi.server.ServerAPI

@Experimental public abstract class ServerAPI extends Object
This class provides some basic functionality to interact with the server. This class is experimental and may change in future versions.
  • Constructor Details

    • ServerAPI

      public ServerAPI()
  • Method Details

    • setServerAPI

      public static void setServerAPI(ServerAPI serverAPI)
      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

      public static ServerAPI 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

      public abstract String getJProVersion()
      Return the version of the currently running JPro server.
      Returns:
      the version string
      Since:
      2024.2.2
    • addRequestHandler

      public abstract void addRequestHandler(Function<Request,Response> handler)
      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

      public abstract void removeRequestHandler(Function<Request,Response> handler)
      Removes a request handler from the server.
      Parameters:
      handler - the function to be removed from handling requests