public class VirtualHostBuilder extends Object
VirtualHost
.
VirtualHostBuilder vhb = new VirtualHostBuilder("*.example.com");
vhb.service("/foo", new FooService())
.serviceUnder("/bar/", new BarService())
.service(PathMapping.ofRegex("^/baz/.*", new BazService());
VirtualHost vh = vhb.build();
PathMapping
Constructor and Description |
---|
VirtualHostBuilder()
Creates a new
VirtualHostBuilder whose hostname pattern is "*" (match-all). |
VirtualHostBuilder(String hostnamePattern)
Creates a new
VirtualHostBuilder with the specified hostname pattern. |
VirtualHostBuilder(String defaultHostname,
String hostnamePattern)
Creates a new
VirtualHostBuilder with
the default host name and the specified hostname pattern. |
Modifier and Type | Method and Description |
---|---|
B |
annotatedService(Object service)
Binds the specified annotated service object under the path prefix
"/" . |
B |
annotatedService(Object service,
Function<Service<HttpRequest,HttpResponse>,? extends Service<HttpRequest,HttpResponse>> decorator,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the path prefix
"/" . |
B |
annotatedService(Object service,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the path prefix
"/" . |
B |
annotatedService(String pathPrefix,
Object service)
Binds the specified annotated service object under the specified path prefix.
|
B |
annotatedService(String pathPrefix,
Object service,
Function<Service<HttpRequest,HttpResponse>,? extends Service<HttpRequest,HttpResponse>> decorator,
Iterable<?> exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
B |
annotatedService(String pathPrefix,
Object service,
Function<Service<HttpRequest,HttpResponse>,? extends Service<HttpRequest,HttpResponse>> decorator,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
B |
annotatedService(String pathPrefix,
Object service,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHost |
build()
Returns a newly-created
VirtualHost based on the properties of this builder and the services
added to this builder. |
<T extends Service<HttpRequest,HttpResponse>,R extends Service<HttpRequest,HttpResponse>> |
decorator(Function<T,R> decorator)
Decorates all
Service s with the specified decorator . |
B |
service(PathMapping pathMapping,
Service<HttpRequest,HttpResponse> service)
Binds the specified
Service at the specified PathMapping . |
B |
service(PathMapping pathMapping,
Service<HttpRequest,HttpResponse> service,
String loggerName)
Deprecated.
Use a logging framework integration such as
RequestContextExportingAppender in
armeria-logback . |
B |
service(String pathPattern,
Service<HttpRequest,HttpResponse> service)
Binds the specified
Service at the specified path pattern. e.g. |
<T extends ServiceWithPathMappings<HttpRequest,HttpResponse>> |
service(T serviceWithPathMappings)
Binds the specified
ServiceWithPathMappings at multiple PathMapping s. |
<T extends ServiceWithPathMappings<HttpRequest,HttpResponse>,R extends Service<HttpRequest,HttpResponse>> |
service(T serviceWithPathMappings,
Function<T,R> decorator)
Decorates and binds the specified
ServiceWithPathMappings at multiple PathMapping s. |
B |
serviceAt(String pathPattern,
Service<HttpRequest,HttpResponse> service)
Deprecated.
Use
service(String, Service) instead. |
B |
serviceUnder(String pathPrefix,
Service<HttpRequest,HttpResponse> service)
Binds the specified
Service under the specified directory. |
B |
sslContext(SessionProtocol protocol,
File keyCertChainFile,
File keyFile)
Deprecated.
Use
tls(File, File) . |
B |
sslContext(SessionProtocol protocol,
File keyCertChainFile,
File keyFile,
String keyPassword)
Deprecated.
|
B |
sslContext(SslContext sslContext)
Deprecated.
Use
tls(SslContext) . |
B |
tls(File keyCertChainFile,
File keyFile)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainFile
and cleartext keyFile . |
B |
tls(File keyCertChainFile,
File keyFile,
String keyPassword)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainFile ,
keyFile and keyPassword . |
B |
tls(SslContext sslContext)
Configures SSL or TLS of this
VirtualHost with the specified SslContext . |
String |
toString() |
public VirtualHostBuilder()
VirtualHostBuilder
whose hostname pattern is "*"
(match-all).public VirtualHostBuilder(String hostnamePattern)
VirtualHostBuilder
with the specified hostname pattern.public VirtualHostBuilder(String defaultHostname, String hostnamePattern)
VirtualHostBuilder
with
the default host name and the specified hostname pattern.public VirtualHost build()
VirtualHost
based on the properties of this builder and the services
added to this builder.public B tls(SslContext sslContext)
VirtualHost
with the specified SslContext
.public B tls(File keyCertChainFile, File keyFile) throws SSLException
VirtualHost
with the specified keyCertChainFile
and cleartext keyFile
.SSLException
public B tls(File keyCertChainFile, File keyFile, @Nullable String keyPassword) throws SSLException
VirtualHost
with the specified keyCertChainFile
,
keyFile
and keyPassword
.SSLException
@Deprecated public B sslContext(SslContext sslContext)
tls(SslContext)
.SslContext
of this VirtualHost
.@Deprecated public B sslContext(SessionProtocol protocol, File keyCertChainFile, File keyFile) throws SSLException
tls(File, File)
.SslContext
of this VirtualHost
from the specified SessionProtocol
,
keyCertChainFile
and cleartext keyFile
.SSLException
@Deprecated public B sslContext(SessionProtocol protocol, File keyCertChainFile, File keyFile, @Nullable String keyPassword) throws SSLException
tls(File, File, String)
.SslContext
of this VirtualHost
from the specified SessionProtocol
,
keyCertChainFile
, keyFile
and keyPassword
.SSLException
@Deprecated public B serviceAt(String pathPattern, Service<HttpRequest,HttpResponse> service)
service(String, Service)
instead.Service
at the specified path pattern.public B serviceUnder(String pathPrefix, Service<HttpRequest,HttpResponse> service)
Service
under the specified directory.public B service(String pathPattern, Service<HttpRequest,HttpResponse> service)
Service
at the specified path pattern. e.g.
/login
(no path parameters)/users/{userId}
(curly-brace style)/list/:productType/by/:ordering
(colon style)exact:/foo/bar
(exact match)prefix:/files
(prefix match)glob:/~*/downloads/**
(glob pattern)regex:^/files/(?<filePath>.*)$
(regular expression)IllegalArgumentException
- if the specified path pattern is invalidpublic B service(PathMapping pathMapping, Service<HttpRequest,HttpResponse> service)
Service
at the specified PathMapping
.@Deprecated public B service(PathMapping pathMapping, Service<HttpRequest,HttpResponse> service, String loggerName)
RequestContextExportingAppender
in
armeria-logback
.Service
at the specified PathMapping
.public <T extends ServiceWithPathMappings<HttpRequest,HttpResponse>> B service(T serviceWithPathMappings)
ServiceWithPathMappings
at multiple PathMapping
s.public <T extends ServiceWithPathMappings<HttpRequest,HttpResponse>,R extends Service<HttpRequest,HttpResponse>> B service(T serviceWithPathMappings, Function<T,R> decorator)
ServiceWithPathMappings
at multiple PathMapping
s.public B annotatedService(Object service)
"/"
.public B annotatedService(Object service, Object... exceptionHandlersAndConverters)
"/"
.exceptionHandlersAndConverters
- instances of ExceptionHandlerFunction
,
RequestConverterFunction
and/or
ResponseConverterFunction
public B annotatedService(Object service, Function<Service<HttpRequest,HttpResponse>,? extends Service<HttpRequest,HttpResponse>> decorator, Object... exceptionHandlersAndConverters)
"/"
.exceptionHandlersAndConverters
- instances of ExceptionHandlerFunction
,
RequestConverterFunction
and/or
ResponseConverterFunction
public B annotatedService(String pathPrefix, Object service)
public B annotatedService(String pathPrefix, Object service, Object... exceptionHandlersAndConverters)
exceptionHandlersAndConverters
- instances of ExceptionHandlerFunction
,
RequestConverterFunction
and/or
ResponseConverterFunction
public B annotatedService(String pathPrefix, Object service, Function<Service<HttpRequest,HttpResponse>,? extends Service<HttpRequest,HttpResponse>> decorator, Object... exceptionHandlersAndConverters)
exceptionHandlersAndConverters
- instances of ExceptionHandlerFunction
,
RequestConverterFunction
and/or
ResponseConverterFunction
public B annotatedService(String pathPrefix, Object service, Function<Service<HttpRequest,HttpResponse>,? extends Service<HttpRequest,HttpResponse>> decorator, Iterable<?> exceptionHandlersAndConverters)
exceptionHandlersAndConverters
- an iterable object of ExceptionHandlerFunction
,
RequestConverterFunction
and/or
ResponseConverterFunction
public <T extends Service<HttpRequest,HttpResponse>,R extends Service<HttpRequest,HttpResponse>> B decorator(Function<T,R> decorator)
Service
s with the specified decorator
.© Copyright 2015–2018 LINE Corporation. All rights reserved.