Class HttpRequestUtils

java.lang.Object
com.ultikits.ultitools.utils.HttpRequestUtils

public class HttpRequestUtils extends Object
Utility class for HTTP request operations. Provides methods for communicating with the UltiPanel API server. This class handles authentication, server registration, and server updates.
HTTP请求操作的实用工具类。 提供与UltiPanel API服务器通信的方法。 此类处理身份验证、服务器注册和服务器更新。
Since:
6.0.0
Author:
wisdomme
  • Field Details

    • baseUrl

      private static volatile String baseUrl
      Base URL for the API server (lazy initialized).
      API服务器的基础URL(延迟初始化)。
    • customBaseUrl

      private static String customBaseUrl
      Custom base URL for testing purposes.
      用于测试的自定义基础URL。
  • Constructor Details

    • HttpRequestUtils

      public HttpRequestUtils()
  • Method Details

    • getBaseUrl

      static String getBaseUrl()
      Get the base URL for API calls. Uses lazy initialization to avoid requiring UltiTools at class loading time.
      获取API调用的基础URL。 使用延迟初始化以避免在类加载时需要UltiTools。
      Returns:
      the base URL
    • setBaseUrlForTesting

      static void setBaseUrlForTesting(String url)
      Set a custom base URL for testing purposes. This should only be used in unit tests.
      设置自定义的基础URL,仅用于测试目的。
      Parameters:
      url - the custom base URL, or null to reset to default
    • resetBaseUrl

      static void resetBaseUrl()
      Reset the base URL to force re-initialization. This should only be used in unit tests.
      重置基础URL以强制重新初始化,仅用于测试目的。
    • getServerByUUID

      protected static SimpleHttpClient.Response getServerByUUID(String uuid, TokenEntity token)
      Get server information by UUID from the API server.
      通过UUID从API服务器获取服务器信息。
      Parameters:
      uuid - the unique identifier of the server
      服务器的唯一标识符
      token - the authentication token
      身份验证令牌
      Returns:
      HttpResponse containing the server information
      包含服务器信息的HttpResponse
    • registerServer

      protected static SimpleHttpClient.Response registerServer(String uuid, String name, int port, String domain, boolean ssl, TokenEntity token)
      Register a new server with the API server.
      向API服务器注册新服务器。
      Parameters:
      uuid - the unique identifier for the server
      服务器的唯一标识符
      name - the display name for the server
      服务器的显示名称
      port - the port number of the server
      服务器的端口号
      domain - the domain name of the server
      服务器的域名
      ssl - whether SSL is enabled
      是否启用SSL
      token - the authentication token
      身份验证令牌
      Returns:
      HttpResponse containing the registration result
      包含注册结果的HttpResponse
    • updateServer

      protected static SimpleHttpClient.Response updateServer(String uuid, int port, String domain, boolean ssl, TokenEntity token)
      Update an existing server on the API server.
      在API服务器上更新现有服务器。
      Parameters:
      uuid - the unique identifier of the server
      服务器的唯一标识符
      port - the new port number
      新的端口号
      domain - the new domain name
      新的域名
      ssl - whether SSL is enabled
      是否启用SSL
      token - the authentication token
      身份验证令牌
      Returns:
      HttpResponse containing the update result
      包含更新结果的HttpResponse