Java Code Examples for com.linecorp.armeria.common.SessionProtocol#uriText()

The following examples show how to use com.linecorp.armeria.common.SessionProtocol#uriText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerRuleDelegate.java    From armeria with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the {@link URI} for the {@link Server} of the specified {@link SessionProtocol} and
 * {@link SerializationFormat}.
 *
 * @throws IllegalStateException if the {@link Server} is not started or
 *                               it did not open the port for the specified {@link SessionProtocol}.
 */
public URI uri(SessionProtocol protocol, SerializationFormat format) {
    requireNonNull(protocol, "protocol");
    requireNonNull(format, "format");

    ensureStarted();

    final int port;
    if (!protocol.isTls() && hasHttp()) {
        port = httpPort();
    } else if (protocol.isTls() && hasHttps()) {
        port = httpsPort();
    } else {
        throw new IllegalStateException("can't find the specified port");
    }

    final String uriStr = protocol.uriText() + "://127.0.0.1:" + port;
    if (format == SerializationFormat.NONE) {
        return URI.create(uriStr);
    } else {
        return URI.create(format.uriText() + '+' + uriStr);
    }
}
 
Example 2
Source File: EurekaUpdatingListener.java    From armeria with Apache License 2.0 6 votes vote down vote up
@Nullable
private static String healthCheckUrl(String hostnameOrIpAddr, @Nullable String oldHealthCheckUrl,
                                     PortWrapper portWrapper,
                                     Optional<ServiceConfig> healthCheckService,
                                     SessionProtocol sessionProtocol) {
    if (oldHealthCheckUrl != null) {
        return oldHealthCheckUrl;
    }
    if (!portWrapper.isEnabled() || !healthCheckService.isPresent()) {
        return null;
    }
    final ServiceConfig healthCheckServiceConfig = healthCheckService.get();
    final Route route = healthCheckServiceConfig.route();
    if (route.pathType() != RoutePathType.EXACT && route.pathType() != RoutePathType.PREFIX) {
        return null;
    }

    return sessionProtocol.uriText() + "://" + hostnameOrIpAddr(hostnameOrIpAddr) +
           ':' + portWrapper.getPort() + route.paths().get(0);
}
 
Example 3
Source File: ThriftOverHttpClientTServletIntegrationTest.java    From armeria with Apache License 2.0 4 votes vote down vote up
private static String http1uri(SessionProtocol protocol) {
    return "tbinary+" + protocol.uriText() + "://127.0.0.1:" + http1Port() + TSERVLET_PATH;
}
 
Example 4
Source File: ThriftOverHttpClientTServletIntegrationTest.java    From armeria with Apache License 2.0 4 votes vote down vote up
private static String http2uri(SessionProtocol protocol) {
    return "tbinary+" + protocol.uriText() + "://127.0.0.1:" + http2Port() + TSERVLET_PATH;
}
 
Example 5
Source File: Exceptions.java    From armeria with Apache License 2.0 4 votes vote down vote up
private static String protocolName(@Nullable SessionProtocol protocol) {
    return protocol != null ? protocol.uriText() : "<unknown>";
}