类 RequestPredicates

java.lang.Object
cn.taketoday.web.handler.function.RequestPredicates

public abstract class RequestPredicates extends Object
Implementations of RequestPredicate that implement various useful request matching operations, such as matching based on path, HTTP method, etc.
从以下版本开始:
4.0
作者:
Arjen Poutsma, Sam Brannen, Harry Yang
  • 字段详细资料

    • logger

      private static final cn.taketoday.logging.Logger logger
  • 构造器详细资料

    • RequestPredicates

      public RequestPredicates()
  • 方法详细资料

    • all

      public static RequestPredicate all()
      Return a RequestPredicate that always matches.
      返回:
      a predicate that always matches
    • method

      public static RequestPredicate method(HttpMethod httpMethod)
      Return a RequestPredicate that matches if the request's HTTP method is equal to the given method.
      参数:
      httpMethod - the HTTP method to match against
      返回:
      a predicate that tests against the given HTTP method
    • methods

      public static RequestPredicate methods(HttpMethod... httpMethods)
      Return a RequestPredicate that matches if the request's HTTP method is equal to one the of the given methods.
      参数:
      httpMethods - the HTTP methods to match against
      返回:
      a predicate that tests against the given HTTP methods
    • path

      public static RequestPredicate path(String pattern)
      Return a RequestPredicate that tests the request path against the given path pattern.
      参数:
      pattern - the pattern to match to
      返回:
      a predicate that tests against the given path pattern
    • pathPredicates

      public static Function<String,RequestPredicate> pathPredicates(PathPatternParser patternParser)
      Return a function that creates new path-matching RequestPredicates from pattern Strings using the given PathPatternParser.

      This method can be used to specify a non-default, customized PathPatternParser when resolving path patterns.

      参数:
      patternParser - the parser used to parse patterns given to the returned function
      返回:
      a function that resolves a pattern String into a path-matching RequestPredicates instance
    • headers

      public static RequestPredicate headers(Predicate<ServerRequest.Headers> headersPredicate)
      Return a RequestPredicate that tests the request's headers against the given headers predicate.
      参数:
      headersPredicate - a predicate that tests against the request headers
      返回:
      a predicate that tests against the given header predicate
    • contentType

      public static RequestPredicate contentType(MediaType... mediaTypes)
      Return a RequestPredicate that tests if the request's content type is included by any of the given media types.
      参数:
      mediaTypes - the media types to match the request's content type against
      返回:
      a predicate that tests the request's content type against the given media types
    • accept

      public static RequestPredicate accept(MediaType... mediaTypes)
      Return a RequestPredicate that tests if the request's accept header is compatible with any of the given media types.
      参数:
      mediaTypes - the media types to match the request's accept header against
      返回:
      a predicate that tests the request's accept header against the given media types
    • GET

      public static RequestPredicate GET(String pattern)
      Return a RequestPredicate that matches if request's HTTP method is GET and the given pattern matches against the request path.
      参数:
      pattern - the path pattern to match against
      返回:
      a predicate that matches if the request method is GET and if the given pattern matches against the request path
    • HEAD

      public static RequestPredicate HEAD(String pattern)
      Return a RequestPredicate that matches if request's HTTP method is HEAD and the given pattern matches against the request path.
      参数:
      pattern - the path pattern to match against
      返回:
      a predicate that matches if the request method is HEAD and if the given pattern matches against the request path
    • POST

      public static RequestPredicate POST(String pattern)
      Return a RequestPredicate that matches if request's HTTP method is POST and the given pattern matches against the request path.
      参数:
      pattern - the path pattern to match against
      返回:
      a predicate that matches if the request method is POST and if the given pattern matches against the request path
    • PUT

      public static RequestPredicate PUT(String pattern)
      Return a RequestPredicate that matches if request's HTTP method is PUT and the given pattern matches against the request path.
      参数:
      pattern - the path pattern to match against
      返回:
      a predicate that matches if the request method is PUT and if the given pattern matches against the request path
    • PATCH

      public static RequestPredicate PATCH(String pattern)
      Return a RequestPredicate that matches if request's HTTP method is PATCH and the given pattern matches against the request path.
      参数:
      pattern - the path pattern to match against
      返回:
      a predicate that matches if the request method is PATCH and if the given pattern matches against the request path
    • DELETE

      public static RequestPredicate DELETE(String pattern)
      Return a RequestPredicate that matches if request's HTTP method is DELETE and the given pattern matches against the request path.
      参数:
      pattern - the path pattern to match against
      返回:
      a predicate that matches if the request method is DELETE and if the given pattern matches against the request path
    • OPTIONS

      public static RequestPredicate OPTIONS(String pattern)
      Return a RequestPredicate that matches if request's HTTP method is OPTIONS and the given pattern matches against the request path.
      参数:
      pattern - the path pattern to match against
      返回:
      a predicate that matches if the request method is OPTIONS and if the given pattern matches against the request path
    • pathExtension

      public static RequestPredicate pathExtension(String extension)
      Return a RequestPredicate that matches if the request's path has the given extension.
      参数:
      extension - the path extension to match against, ignoring case
      返回:
      a predicate that matches if the request's path has the given file extension
    • pathExtension

      public static RequestPredicate pathExtension(Predicate<String> extensionPredicate)
      Return a RequestPredicate that matches if the request's path matches the given predicate.
      参数:
      extensionPredicate - the predicate to test against the request path extension
      返回:
      a predicate that matches if the given predicate matches against the request's path file extension
    • param

      public static RequestPredicate param(String name)
      Return a RequestPredicate that matches if the request's parameter of the given name has the given value.
      参数:
      name - the name of the parameter to test against
      返回:
      a predicate that matches if the parameter has the given value
      另请参阅:
    • param

      public static RequestPredicate param(String name, String value)
      Return a RequestPredicate that matches if the request's parameter of the given name has the given value.
      参数:
      name - the name of the parameter to test against
      value - the value of the parameter to test against
      返回:
      a predicate that matches if the parameter has the given value
      另请参阅:
    • param

      public static RequestPredicate param(String name, Predicate<String> predicate)
      Return a RequestPredicate that tests the request's parameter of the given name against the given predicate.
      参数:
      name - the name of the parameter to test against
      predicate - the predicate to test against the parameter value
      返回:
      a predicate that matches the given predicate against the parameter of the given name
      另请参阅:
    • traceMatch

      private static void traceMatch(String prefix, Object desired, @Nullable Object actual, boolean match)
    • mergePathVariables

      private static Map<String,String> mergePathVariables(Map<String,String> oldVariables, Map<String,String> newVariables)
    • mergePatterns

      private static PathPattern mergePatterns(@Nullable PathPattern oldPattern, PathPattern newPattern)