Class PredicateSpec

    • Method Detail

      • predicate

        public BooleanSpec predicate​(Predicate<org.springframework.web.server.ServerWebExchange> predicate)
      • asyncPredicate

        public BooleanSpec asyncPredicate​(AsyncPredicate<org.springframework.web.server.ServerWebExchange> predicate)
      • cookie

        public BooleanSpec cookie​(String name,
                                  String regex)
        A predicate that checks if a cookie matches a given regular expression.
        Parameters:
        name - the name of the cookie
        regex - the value of the cookies will be evaluated against this regular expression
        Returns:
        a BooleanSpec to be used to add logical operators
      • header

        public BooleanSpec header​(String header)
        A predicate that checks if a given header is present on the request.
        Parameters:
        header - the header name to check
        Returns:
        a BooleanSpec to be used to add logical operators
      • header

        public BooleanSpec header​(String header,
                                  String regex)
        A predicate that checks if a given headers has a value which matches a regular expression.
        Parameters:
        header - the header name to check
        regex - the regular expression to check against
        Returns:
        a BooleanSpec to be used to add logical operators
      • host

        public BooleanSpec host​(String... pattern)
        A predicate that checks if the host header matches a given pattern.
        Parameters:
        pattern - the pattern to check against. The pattern is an Ant style pattern with . as a separator
        Returns:
        a BooleanSpec to be used to add logical operators
      • method

        public BooleanSpec method​(String... methods)
        A predicate that checks if the HTTP method matches.
        Parameters:
        methods - the name of the HTTP methods
        Returns:
        a BooleanSpec to be used to add logical operators
      • method

        public BooleanSpec method​(org.springframework.http.HttpMethod... methods)
        A predicate that checks if the HTTP method matches.
        Parameters:
        methods - the HTTP methods
        Returns:
        a BooleanSpec to be used to add logical operators
      • path

        public BooleanSpec path​(String... patterns)
        A predicate that checks if the path of the request matches the given pattern.
        Parameters:
        patterns - the pattern to check the path against. The pattern is a PathMatcher pattern
        Returns:
        a BooleanSpec to be used to add logical operators
      • path

        public BooleanSpec path​(boolean matchTrailingSlash,
                                String... patterns)
        A predicate that checks if the path of the request matches the given pattern.
        Parameters:
        patterns - the pattern to check the path against. The pattern is a PathMatcher pattern
        matchTrailingSlash - set to false if you do not want this path to match when there is a trailing /
        Returns:
        a BooleanSpec to be used to add logical operators
      • readBody

        public <T> BooleanSpec readBody​(Class<T> inClass,
                                        Predicate<T> predicate)
        This predicate is BETA and may be subject to change in a future release. A predicate that checks the contents of the request body
        Type Parameters:
        T - the type the body is parsed to
        Parameters:
        inClass - the class to parse the body to
        predicate - a predicate to check the contents of the body
        Returns:
        a BooleanSpec to be used to add logical operators
      • query

        public BooleanSpec query​(String param,
                                 String regex)
        A predicate that checks if a query parameter matches a regular expression.
        Parameters:
        param - the query parameter name
        regex - the regular expression to evaluate the query parameter value against
        Returns:
        a BooleanSpec to be used to add logical operators
      • query

        public BooleanSpec query​(String param)
        A predicate that checks if a given query parameter is present in the request URL.
        Parameters:
        param - the query parameter name
        Returns:
        a BooleanSpec to be used to add logical operators
      • remoteAddr

        public BooleanSpec remoteAddr​(String... addrs)
        A predicate which checks the remote address of the request. By default the RemoteAddr Route Predicate Factory uses the remote address from the incoming request. This may not match the actual client IP address if Spring Cloud Gateway sits behind a proxy layer. Use remoteAddr(RemoteAddressResolver, String...) to customize the resolver. You can customize the way that the remote address is resolved by setting a custom RemoteAddressResolver.
        Parameters:
        addrs - the remote address to verify. Should use CIDR-notation (IPv4 or IPv6) strings.
        Returns:
        a BooleanSpec to be used to add logical operators
      • remoteAddr

        public BooleanSpec remoteAddr​(RemoteAddressResolver resolver,
                                      String... addrs)
        A predicate which checks the remote address of the request. Useful if Spring Cloud Gateway site behind a proxy layer. Spring Cloud Gateway comes with one non-default remote address resolver which is based off of the X-Forwarded-For header, XForwardedRemoteAddressResolver. See XForwardedRemoteAddressResolver for more information.
        Parameters:
        resolver - the RemoteAddressResolver to use to resolve the remote IP address against
        addrs - the remote address to verify. Should use CIDR-notation (IPv4 or IPv6) strings.
        Returns:
        a BooleanSpec to be used to add logical operators
      • xForwardedRemoteAddr

        public BooleanSpec xForwardedRemoteAddr​(String... addrs)
        A predicate which checks the remote address of the request based off of the X-Forwarded-For header. Useful if Spring Cloud Gateway site behind a proxy layer. See XForwardedRemoteAddressResolver for more information.
        Parameters:
        addrs - the remote address to verify. Should use CIDR-notation (IPv4 or IPv6) strings.
        Returns:
        a BooleanSpec to be used to add logical operators
      • weight

        public BooleanSpec weight​(String group,
                                  int weight)
        A predicate which will select a route based on its assigned weight.
        Parameters:
        group - the group the route belongs to
        weight - the weight for the route
        Returns:
        a BooleanSpec to be used to add logical operators
      • cloudFoundryRouteService

        public BooleanSpec cloudFoundryRouteService()
      • alwaysTrue

        public BooleanSpec alwaysTrue()
        A predicate which is always true.
        Returns:
        a BooleanSpec to be used to add logical operators