Record Class PublicServerUrl

java.lang.Object
java.lang.Record
io.leandev.appfuse.web.url.PublicServerUrl
Record Components:
baseUri - 完整 HTTP(S) 基底,不含 userinfo、query 或 fragment

public record PublicServerUrl(URI baseUri) extends Record

已驗證的 Server 對外基底;不依 Servlet context、request 或應用設定推算。

endpoint 與 segment 接受未編碼值;query 值由 uri 方法編碼一次。 endpoint 不接受 query/fragment;動態 segment 不接受斜線、反斜線、百分號或 dot segment。 scheme/host 大小寫、預設 port、尾端單一斜線與 unreserved percent-encoding 會正規化。 這是位址組合能力,不判斷目的地是否可信、不執行網路請求、不提供租戶授權。

  • Constructor Details

    • PublicServerUrl

      public PublicServerUrl(URI baseUri)
      Creates an instance of a PublicServerUrl record class.
      Parameters:
      baseUri - the value for the baseUri record component
  • Method Details

    • of

      public static PublicServerUrl of(String value)
    • cookiePath

      public String cookiePath()
      根部署回傳 /,其餘回傳無尾斜線的對外 Path;適用 Session Cookie。
    • path

      public String path(String endpoint, String... segments)
      endpoint 相對於 Server base;額外動態值逐 segment 編碼,不可傳入預編碼值。
    • uri

      public URI uri(String endpoint, String... segments)
    • uri

      public URI uri(String endpoint, Map<String,String> query, String... segments)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • baseUri

      public URI baseUri()
      Returns the value of the baseUri record component.
      Returns:
      the value of the baseUri record component