Example usage for io.netty.util DomainNameMapping map

List of usage examples for io.netty.util DomainNameMapping map

Introduction

In this page you can find the example usage for io.netty.util DomainNameMapping map.

Prototype

Map map

To view the source code for io.netty.util DomainNameMapping map.

Click Source Link

Usage

From source file:com.linecorp.armeria.server.VirtualHost.java

License:Apache License

/**
 * Ensure that 'hostnamePattern' matches 'defaultHostname'.
 *//*from  ww w  . j av a2s  .  c o  m*/
static void ensureHostnamePatternMatchesDefaultHostname(String hostnamePattern, String defaultHostname) {
    if ("*".equals(hostnamePattern)) {
        return;
    }

    // Pretty convoluted way to validate but it's done only once and
    // we don't need to duplicate the pattern matching logic.
    final DomainNameMapping<Boolean> mapping = new DomainNameMappingBuilder<>(Boolean.FALSE)
            .add(hostnamePattern, Boolean.TRUE).build();

    if (!mapping.map(defaultHostname)) {
        throw new IllegalArgumentException("defaultHostname: " + defaultHostname
                + " (must be matched by hostnamePattern: " + hostnamePattern + ')');
    }
}