Class ContextHelper

  • All Implemented Interfaces:
    HttpConstants

    public final class ContextHelper
    extends Object
    implements HttpConstants
    A helper for the web context.
    Since:
    1.8.1
    Author:
    Jerome Leleu
    • Constructor Detail

      • ContextHelper

        public ContextHelper()
    • Method Detail

      • getCookie

        public static Cookie getCookie​(Collection<Cookie> cookies,
                                       String name)
        Get a specific cookie by its name.
        Parameters:
        cookies - provided cookies
        name - the name of the cookie
        Returns:
        the cookie
      • getCookie

        public static Cookie getCookie​(WebContext context,
                                       String name)
        Get a specific cookie by its name.
        Parameters:
        context - the current web context
        name - the name of the cookie
        Returns:
        the cookie
      • isGet

        public static boolean isGet​(WebContext context)
        Whether it is a GET request.
        Parameters:
        context - the web context
        Returns:
        whether it is a GET request
      • isPost

        public static boolean isPost​(WebContext context)
        Whether it is a POST request.
        Parameters:
        context - the web context
        Returns:
        whether it is a POST request
      • isPut

        public static boolean isPut​(WebContext context)
        Whether it is a PUT request.
        Parameters:
        context - the web context
        Returns:
        whether it is a PUT request
      • isPatch

        public static boolean isPatch​(WebContext context)
        Whether it is a PATCH request.
        Parameters:
        context - the web context
        Returns:
        whether it is a PATCH request
      • isDelete

        public static boolean isDelete​(WebContext context)
        Whether it is a DELETE request.
        Parameters:
        context - the web context
        Returns:
        whether it is a DELETE request
      • isHttpsOrSecure

        public static boolean isHttpsOrSecure​(WebContext context)
        Whether the request is HTTPS or secure.
        Parameters:
        context - the current web context
        Returns:
        whether the request is HTTPS or secure
      • isHttp

        public static boolean isHttp​(WebContext context)
        Whether the request is HTTP.
        Parameters:
        context - the current web context
        Returns:
        whether the request is HTTP
      • isHttps

        public static boolean isHttps​(WebContext context)
        Whether the request is HTTPS.
        Parameters:
        context - the current web context
        Returns:
        whether the request is HTTPS