本文整理了Java中com.linecorp.armeria.server.VirtualHost.defaultHostname()
方法的一些代码示例,展示了VirtualHost.defaultHostname()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。VirtualHost.defaultHostname()
方法的具体详情如下:
包路径:com.linecorp.armeria.server.VirtualHost
类名称:VirtualHost
方法名:defaultHostname
[英]Returns the default hostname of this virtual host.
[中]返回此虚拟主机的默认主机名。
代码示例来源:origin: line/armeria
private String hostname(ChannelHandlerContext ctx, HttpHeaders headers) {
final String hostname = headers.authority();
if (hostname == null) {
// Fill the authority with the default host name and current port, just in case the client did not
// send it.
final String defaultHostname = config.defaultVirtualHost().defaultHostname();
final int port = ((InetSocketAddress) ctx.channel().localAddress()).getPort();
headers.authority(defaultHostname + ':' + port);
return defaultHostname;
}
final int hostnameColonIdx = hostname.lastIndexOf(':');
if (hostnameColonIdx < 0) {
return hostname;
}
return hostname.substring(0, hostnameColonIdx);
}
代码示例来源:origin: line/armeria
/**
* Returns the hostname of the default {@link VirtualHost}, which is the hostname of the machine unless
* configured explicitly via {@link ServerBuilder#defaultVirtualHost(VirtualHost)}.
*/
public String defaultHostname() {
return config().defaultVirtualHost().defaultHostname();
}
代码示例来源:origin: line/armeria
@Override
public String toString() {
String strVal = this.strVal;
if (strVal == null) {
this.strVal = strVal = toString(
getClass(), defaultHostname(), hostnamePattern(), sslContext(), serviceConfigs());
}
return strVal;
}
代码示例来源:origin: line/armeria
VirtualHost decorate(@Nullable Function<Service<HttpRequest, HttpResponse>,
Service<HttpRequest, HttpResponse>> decorator) {
if (decorator == null) {
return this;
}
final List<ServiceConfig> services =
this.services.stream().map(cfg -> {
final PathMapping pathMapping = cfg.pathMapping();
final Service<HttpRequest, HttpResponse> service = decorator.apply(cfg.service());
final String loggerName = cfg.loggerName().orElse(null);
return new ServiceConfig(pathMapping, service, loggerName);
}).collect(Collectors.toList());
return new VirtualHost(defaultHostname(), hostnamePattern(), sslContext(),
services, producibleMediaTypes());
}
代码示例来源:origin: line/armeria
.append(sessionProtocol().uriText())
.append("://")
.append(virtualHost().defaultHostname());
代码示例来源:origin: line/armeria
private VirtualHost normalizeDefaultVirtualHost(VirtualHost h,
@Nullable SslContext defaultSslContext) {
final SslContext sslCtx = h.sslContext() != null ? h.sslContext() : defaultSslContext;
return new VirtualHost(
h.defaultHostname(), "*", sslCtx,
h.serviceConfigs().stream().map(
e -> new ServiceConfig(e.pathMapping(), e.service(), e.loggerName().orElse(null)))
.collect(Collectors.toList()), h.producibleMediaTypes(),
rejectedPathMappingHandler, host -> h.accessLogger());
}
代码示例来源:origin: line/armeria
if (!virtualHosts.isEmpty()) {
virtualHosts.forEach(c -> {
buf.append(VirtualHost.toString(null, c.defaultHostname(), c.hostnamePattern(),
c.sslContext(), c.serviceConfigs()));
buf.append(", ");
buf.append(VirtualHost.toString(null, defaultVirtualHost.defaultHostname(), "*",
defaultVirtualHost.sslContext(),
defaultVirtualHost.serviceConfigs()));
buf.append(VirtualHost.toString(null, defaultVirtualHost.defaultHostname(), "*",
defaultVirtualHost.sslContext(),
defaultVirtualHost.serviceConfigs()));
代码示例来源:origin: line/armeria
final ServiceRequestContext sCtx = (ServiceRequestContext) ctx;
final int port = ((InetSocketAddress) sCtx.remoteAddress()).getPort();
final String hostname = sCtx.virtualHost().defaultHostname();
if (port == ctx.sessionProtocol().defaultPort()) {
authority = hostname;
代码示例来源:origin: line/armeria
@Override
public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) throws Exception {
final SamlServiceFunction func = serviceMap.get(req.path());
if (func == null) {
return HttpResponse.of(HttpStatus.BAD_REQUEST);
}
final CompletionStage<AggregatedHttpMessage> f;
if (portConfigHolder.isDone()) {
f = req.aggregate();
} else {
f = portConfigHolder.future().thenCompose(unused -> req.aggregate());
}
return HttpResponse.from(f.handle((msg, cause) -> {
if (cause != null) {
return HttpResponse.of(HttpStatus.BAD_REQUEST);
}
final SamlPortConfig portConfig = portConfigHolder.config().get();
if (portConfig.scheme().isTls() != ctx.sessionProtocol().isTls()) {
return HttpResponse.of(HttpStatus.BAD_REQUEST);
}
// Use user-specified hostname if it exists.
// If there's no hostname set by a user, the default virtual hostname will be used.
final String defaultHostname = firstNonNull(sp.hostname(), ctx.virtualHost().defaultHostname());
return func.serve(ctx, msg, defaultHostname, portConfig);
}));
}
代码示例来源:origin: line/armeria
throw new RuntimeException("cannot find a suitable identity provider from configurations");
final String defaultHostname = firstNonNull(sp.hostname(), ctx.virtualHost().defaultHostname());
final AuthnRequest request = createAuthRequest(idp, defaultHostname);
final MessageContext<AuthnRequest> messageContext = new MessageContext<>();
代码示例来源:origin: com.linecorp.armeria/armeria-logback-shaded
final ServiceRequestContext sCtx = (ServiceRequestContext) ctx;
final int port = ((InetSocketAddress) sCtx.remoteAddress()).getPort();
final String hostname = sCtx.virtualHost().defaultHostname();
if (port == ctx.sessionProtocol().defaultPort()) {
authority = hostname;
代码示例来源:origin: com.linecorp.armeria/armeria-logback
final ServiceRequestContext sCtx = (ServiceRequestContext) ctx;
final int port = ((InetSocketAddress) sCtx.remoteAddress()).getPort();
final String hostname = sCtx.virtualHost().defaultHostname();
if (port == ctx.sessionProtocol().defaultPort()) {
authority = hostname;
代码示例来源:origin: com.linecorp.armeria/armeria-saml
@Override
public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) throws Exception {
final SamlServiceFunction func = serviceMap.get(req.path());
if (func == null) {
return HttpResponse.of(HttpStatus.BAD_REQUEST);
}
final CompletionStage<AggregatedHttpMessage> f;
if (portConfigHolder.isDone()) {
f = req.aggregate();
} else {
f = portConfigHolder.future().thenCompose(unused -> req.aggregate());
}
return HttpResponse.from(f.handle((msg, cause) -> {
if (cause != null) {
return HttpResponse.of(HttpStatus.BAD_REQUEST);
}
final SamlPortConfig portConfig = portConfigHolder.config().get();
if (portConfig.scheme().isTls() != ctx.sessionProtocol().isTls()) {
return HttpResponse.of(HttpStatus.BAD_REQUEST);
}
// Use user-specified hostname if it exists.
// If there's no hostname set by a user, the default virtual hostname will be used.
final String defaultHostname = firstNonNull(sp.hostname(), ctx.virtualHost().defaultHostname());
return func.serve(ctx, msg, defaultHostname, portConfig);
}));
}
代码示例来源:origin: com.linecorp.armeria/armeria-saml
throw new RuntimeException("cannot find a suitable identity provider from configurations");
final String defaultHostname = firstNonNull(sp.hostname(), ctx.virtualHost().defaultHostname());
final AuthnRequest request = createAuthRequest(idp, defaultHostname);
final MessageContext<AuthnRequest> messageContext = new MessageContext<>();
内容来源于网络,如有侵权,请联系作者删除!