Class GuardAction

java.lang.Object
org.frontcache.guard.GuardAction

public class GuardAction extends Object
What a matching guard rule does with the request: reject it, redirect it, or explicitly let it through (an exemption placed above a broader rule).
  • Field Details

  • Method Details

    • reject

      public static GuardAction reject(int status, String body)
    • redirect

      public static GuardAction redirect(int status, String target)
    • allow

      public static GuardAction allow()
    • getType

      public GuardAction.Type getType()
    • getStatus

      public int getStatus()
    • getBody

      public String getBody()
    • getTarget

      public String getTarget()
      Returns:
      redirect target as configured, placeholders NOT expanded
    • getDisposition

      public String getDisposition()
      Returns:
      the disposition string for the log line, or null for ALLOW (not logged)
    • resolveTarget

      public String resolveTarget(RequestContext context)
      Expands ${uri} / ${query} / ${url} / ${url:enc} / ${host} in the redirect target.
      Parameters:
      context - current request
      Returns:
      target ready for the Location header
    • requestURL

      public static String requestURL(RequestContext context)
      Full request URL, as the client would have to type it to get back here. Built here rather than taken from RequestContext.getCurrentRequestURL(), which FrontCacheEngine only populates later and only for cacheable requests - guards run before that. Note the two independent substitutions relative to what the socket saw: the host (see publicHost(RequestContext)) and the scheme. Behind a TLS-terminating proxy the connection reaching this process is plaintext, so the scheme comes from RequestContext.getPublicProtocol() (X-Forwarded-Proto from a trusted peer, or front-cache.public-scheme) and only then from the connection. On the hobbyray edges roughly one request in ten arrived over the plaintext leg, and each one produced an http:// return URL for an https-only site.
    • toString

      public String toString()
      Overrides:
      toString in class Object