Class CORSFilter

  • All Implemented Interfaces:
    io.vertx.core.Handler<io.vertx.ext.web.RoutingContext>

    public class CORSFilter
    extends Object
    implements io.vertx.core.Handler<io.vertx.ext.web.RoutingContext>
    • Constructor Detail

      • CORSFilter

        public CORSFilter​(CORSConfig corsConfig)
    • Method Detail

      • isConfiguredWithWildcard

        public static boolean isConfiguredWithWildcard​(Optional<List<String>> optionalList)
      • parseAllowedOriginsRegex

        public static List<Pattern> parseAllowedOriginsRegex​(Optional<List<String>> allowedOrigins)
        Parse the provided allowed origins for any regexes
        Parameters:
        allowedOrigins -
        Returns:
        a list of compiled regular expressions. If none configured, and empty list is returned
      • isOriginAllowedByRegex

        public static boolean isOriginAllowedByRegex​(List<Pattern> allowOriginsRegex,
                                                     String origin)
        If any regular expression origins are configured, try to match on them. Regular expressions must begin and end with '/'
        Parameters:
        allowOriginsRegex - the configured regex origins.
        origin - the specified origin
        Returns:
        true if any configured regular expressions match the specified origin, false otherwise
      • handle

        public void handle​(io.vertx.ext.web.RoutingContext event)
        Specified by:
        handle in interface io.vertx.core.Handler<io.vertx.ext.web.RoutingContext>
      • isSameOrigin

        static boolean isSameOrigin​(io.vertx.core.http.HttpServerRequest request,
                                    String origin)
      • isSameOriginSlowPath

        static boolean isSameOriginSlowPath​(io.vertx.core.http.HttpServerRequest request,
                                            String origin)
      • substringMatch

        static boolean substringMatch​(String str,
                                      int pos,
                                      String substring,
                                      boolean requireFull)