Class ApiHttpPolicyHandler

java.lang.Object
com.kingsrook.qqq.api.javalin.ApiHttpPolicyHandler

public final class ApiHttpPolicyHandler extends Object
Applies an ApiHttpPolicy to requests and responses of one API instance: CORS before the request is handled, cache headers and validators after.
  • Field Details

  • Method Details

    • hasCredentials

      public static boolean hasCredentials(io.javalin.http.Context context)
      Whether the request carries any credential QQQ would authenticate.
    • isPublicRead

      public static boolean isPublicRead(io.javalin.http.Context context)
      A GET or HEAD request without credentials.
    • applyCors

      public static void applyCors(io.javalin.http.Context context, ApiHttpPolicy policy)
      Before-handler: CORS headers.
    • applyCaching

      public static void applyCaching(io.javalin.http.Context context, ApiHttpPolicy policy)
      After-handler: cache headers, ETag and 304 for public reads; private, no-store for everything else.
    • weakEtag

      public static String weakEtag(byte[] body)
      Weak entity tag over the body: W/"base64url(first 16 bytes of SHA-256)".
    • ifNoneMatchMatches

      public static boolean ifNoneMatchMatches(String ifNoneMatch, String etag)
      Weak comparison of an If-None-Match header against an entity tag (RFC 9110 13.1.2): any listed tag, ignoring the W/ prefix, or "*".