/** * Sets the access logger mapper of this {@link VirtualHost}. * When {@link #build()} is called, this {@link VirtualHost} gets {@link Logger} * via the {@code mapper} for writing access logs. */ public B accessLogger(Function<VirtualHost, Logger> mapper) { accessLoggerMapper = requireNonNull(mapper, "mapper"); return self(); }
/** * Decorates all {@link Service}s with the specified {@code decorator}. * * @param decorator the {@link Function} that decorates a {@link Service} * @param <T> the type of the {@link Service} being decorated * @param <R> the type of the {@link Service} {@code decorator} will produce */ public <T extends Service<HttpRequest, HttpResponse>, R extends Service<HttpRequest, HttpResponse>> B decorator(Function<T, R> decorator) { requireNonNull(decorator, "decorator"); @SuppressWarnings("unchecked") final Function<Service<HttpRequest, HttpResponse>, Service<HttpRequest, HttpResponse>> castDecorator = (Function<Service<HttpRequest, HttpResponse>, Service<HttpRequest, HttpResponse>>) decorator; if (this.decorator != null) { this.decorator = this.decorator.andThen(castDecorator); } else { this.decorator = castDecorator; } return self(); }
/** * Binds the specified {@link Service} at the specified {@link PathMapping}. */ public B service(PathMapping pathMapping, Service<HttpRequest, HttpResponse> service) { services.add(new ServiceConfig(pathMapping, service, null)); return self(); }
/** * Sets the {@link SslContext} of this {@link VirtualHost} from the specified {@link SessionProtocol}, * {@code keyCertChainFile} and cleartext {@code keyFile}. * * @deprecated Use {@link #tls(File, File)}. */ @Deprecated public B sslContext( SessionProtocol protocol, File keyCertChainFile, File keyFile) throws SSLException { sslContext(protocol, keyCertChainFile, keyFile, null); return self(); }
/** * Configures SSL or TLS of this {@link VirtualHost} with the specified {@code keyCertChainFile} * and cleartext {@code keyFile}. */ public B tls(File keyCertChainFile, File keyFile) throws SSLException { tls(keyCertChainFile, keyFile, null); return self(); }
/** * Configures SSL or TLS of this {@link VirtualHost} with the specified {@link SslContext}. */ public B tls(SslContext sslContext) { this.sslContext = VirtualHost.validateSslContext(requireNonNull(sslContext, "sslContext")); return self(); }
/** * Binds the specified {@link Service} at the specified {@link PathMapping}. * * @deprecated Use a logging framework integration such as {@code RequestContextExportingAppender} in * {@code armeria-logback}. */ @Deprecated public B service(PathMapping pathMapping, Service<HttpRequest, HttpResponse> service, String loggerName) { services.add(new ServiceConfig(pathMapping, service, loggerName)); return self(); }
/** * Decorates and binds the specified {@link ServiceWithPathMappings} at multiple {@link PathMapping}s. */ public <T extends ServiceWithPathMappings<HttpRequest, HttpResponse>, R extends Service<HttpRequest, HttpResponse>> B service(T serviceWithPathMappings, Function<? super T, R> decorator) { requireNonNull(serviceWithPathMappings, "serviceWithPathMappings"); requireNonNull(serviceWithPathMappings.pathMappings(), "serviceWithPathMappings.pathMappings()"); requireNonNull(decorator, "decorator"); final Service<HttpRequest, HttpResponse> decorated = decorator.apply(serviceWithPathMappings); serviceWithPathMappings.pathMappings().forEach(pathMapping -> service(pathMapping, decorated)); return self(); }
/** * Binds the specified {@link Service} under the specified directory. */ public B serviceUnder(String pathPrefix, Service<HttpRequest, HttpResponse> service) { service(PathMapping.ofPrefix(pathPrefix), service); return self(); }
/** * Binds the specified {@link Service} at the specified path pattern. e.g. * <ul> * <li>{@code /login} (no path parameters)</li> * <li>{@code /users/{userId}} (curly-brace style)</li> * <li>{@code /list/:productType/by/:ordering} (colon style)</li> * <li>{@code exact:/foo/bar} (exact match)</li> * <li>{@code prefix:/files} (prefix match)</li> * <li><code>glob:/~*/downloads/**</code> (glob pattern)</li> * <li>{@code regex:^/files/(?<filePath>.*)$} (regular expression)</li> * </ul> * * @throws IllegalArgumentException if the specified path pattern is invalid */ public B service(String pathPattern, Service<HttpRequest, HttpResponse> service) { service(PathMapping.of(pathPattern), service); return self(); }
return self();
return self();