本文整理匯總了Java中com.linecorp.armeria.server.file.HttpFileService類的典型用法代碼示例。如果您正苦於以下問題:Java HttpFileService類的具體用法?Java HttpFileService怎麽用?Java HttpFileService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HttpFileService類屬於com.linecorp.armeria.server.file包,在下文中一共展示了HttpFileService類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DocService
import com.linecorp.armeria.server.file.HttpFileService; //導入依賴的package包/類
/**
* Creates a new instance with example HTTP headers and example requests.
*/
DocService(Map<String, ListMultimap<String, HttpHeaders>> exampleHttpHeaders,
Map<String, ListMultimap<String, String>> exampleRequests) {
super(ofExact("/specification.json", HttpFileService.forVfs(new DocServiceVfs())),
ofCatchAll(HttpFileService.forClassPath(DocService.class.getClassLoader(),
"com/linecorp/armeria/server/docs")));
this.exampleHttpHeaders = immutableCopyOf(exampleHttpHeaders, "exampleHttpHeaders");
this.exampleRequests = immutableCopyOf(exampleRequests, "exampleRequests");
}
示例2: configureHttpApi
import com.linecorp.armeria.server.file.HttpFileService; //導入依賴的package包/類
private void configureHttpApi(ServerBuilder sb,
ProjectManager pm, CommandExecutor executor, WatchService watchService,
@Nullable CentralDogmaSecurityManager securityManager) {
final String apiV0PathPrefix = "/api/v0/";
final TokenService tokenService = new TokenService(pm, executor);
final MetadataService mds = new MetadataService(pm, executor);
final Function<Service<HttpRequest, HttpResponse>,
? extends Service<HttpRequest, HttpResponse>> decorator;
if (cfg.isSecurityEnabled()) {
requireNonNull(securityManager, "securityManager");
sb.service(apiV0PathPrefix + "authenticate", new LoginService(securityManager, executor))
.service(apiV0PathPrefix + "logout", new LogoutService(securityManager, executor));
final ApplicationTokenAuthorizer ata = new ApplicationTokenAuthorizer(tokenService::findToken);
final SessionTokenAuthorizer sta = new SessionTokenAuthorizer(securityManager);
decorator = HttpAuthService.newDecorator(ata, sta);
} else {
decorator = HttpAuthService.newDecorator(new CsrfTokenAuthorizer());
}
final SafeProjectManager safePm = new SafeProjectManager(pm);
final HttpApiRequestConverter v1RequestConverter = new HttpApiRequestConverter(safePm);
final HttpApiResponseConverter v1ResponseConverter = new HttpApiResponseConverter();
sb.annotatedService(API_V1_PATH_PREFIX,
new ProjectServiceV1(safePm, executor, mds), decorator,
v1RequestConverter, v1ResponseConverter);
sb.annotatedService(API_V1_PATH_PREFIX,
new RepositoryServiceV1(safePm, executor, mds), decorator,
v1RequestConverter, v1ResponseConverter);
sb.annotatedService(API_V1_PATH_PREFIX,
new ContentServiceV1(safePm, executor, watchService), decorator,
v1RequestConverter, v1ResponseConverter);
if (cfg.isWebAppEnabled()) {
final RestfulJsonResponseConverter httpApiV0Converter = new RestfulJsonResponseConverter();
// TODO(hyangtack): Simplify this if https://github.com/line/armeria/issues/582 is resolved.
sb.annotatedService(apiV0PathPrefix, new UserService(safePm, executor),
decorator, httpApiV0Converter)
.annotatedService(apiV0PathPrefix, new ProjectService(safePm, executor),
decorator, httpApiV0Converter)
.annotatedService(apiV0PathPrefix, new RepositoryService(safePm, executor),
decorator, httpApiV0Converter)
.annotatedService(apiV0PathPrefix, tokenService, decorator, httpApiV0Converter);
}
sb.serviceUnder("/", HttpFileService.forClassPath("webapp"));
}
示例3: StaticSiteService
import com.linecorp.armeria.server.file.HttpFileService; //導入依賴的package包/類
private StaticSiteService(String staticPath, HttpFileService fileService) {
super(
CompositeServiceEntry.ofPrefix(staticPath, fileService),
CompositeServiceEntry.ofExact("/sw.js", fileService),
CompositeServiceEntry.ofCatchAll(fileService.decorate(IndexService::new)));
}
示例4: vfs
import com.linecorp.armeria.server.file.HttpFileService; //導入依賴的package包/類
DocServiceVfs vfs() {
return (DocServiceVfs) ((HttpFileService) serviceAt(0)).config().vfs();
}
示例5: of
import com.linecorp.armeria.server.file.HttpFileService; //導入依賴的package包/類
/**
* Creates a new {@link StaticSiteService}.
*
* @param staticPath the URL path from which static resources will be served, e.g., "/static".
* @param classpathRoot the root directory in the classpath to serve resources from.
*/
public static StaticSiteService of(String staticPath, String classpathRoot) {
HttpFileService fileService =
HttpFileServiceBuilder.forClassPath(classpathRoot).serveCompressedFiles(true).build();
return new StaticSiteService(staticPath, fileService);
}