Interface UrlBuilder


public interface UrlBuilder
Interface for conditions / transformers to contribute information to a resource URL.

The contract for URL contributors is as follows:

  • The transformer must always return exactly the same resource for the same url.
  • When generating a URL, add values to the hash via addToHash(String, Object) and / or the querystring addToQueryString(String, String). This is done at page-render time (when rendering the URLs).
  • If you need to reference values at resource-fetch time (when the js / css resources are being served), add values to the querystring. An example is the locale parameter in the i18n transformer; this adds the user's locale to the URL at page-render time and uses that locale value to transform the resource at resource-fetch time.
  • If you don't need them at resource-fetch time (ie it is there only to add uniqueness), use the hash.
  • You do not need to add a value to the hash AND querystring - adding to the querystring ensures uniqueness.
  • Be sparing in contributing to the querystring. If a single batch has many different transformers contributing to the URL, we will see exponential explosion in the number of combinations of query values that can be seen.
Since:
6.3.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addToHash(String name, Object value)
    Contributes to the url's static hash
    void
    Contributes to the url's querystring
  • Method Details

    • addToHash

      void addToHash(String name, @Nullable Object value)
      Contributes to the url's static hash
      Parameters:
      name - name of the hash. This is used for logging and debugging only.
      value - value to contribute to the hash. The value will be converted to a String using value.toString() when hashing. Can be null.
    • addToQueryString

      void addToQueryString(String key, String value)
      Contributes to the url's querystring
      Parameters:
      key - query key
      value - query value