Exemplo n.º 1
0
  static {
    try {
      tmpDir = Files.createTempDirectory("armeria-test.").toFile();
    } catch (Exception e) {
      throw new Error(e);
    }

    final ServerBuilder sb = new ServerBuilder();

    try {
      sb.port(0, SessionProtocol.HTTP);

      final VirtualHostBuilder defaultVirtualHost = new VirtualHostBuilder();

      defaultVirtualHost.serviceUnder(
          "/fs/", HttpFileService.forFileSystem(tmpDir.toPath()).decorate(LoggingService::new));

      defaultVirtualHost.serviceUnder(
          "/", HttpFileService.forClassPath("/http_file_service").decorate(LoggingService::new));

      sb.defaultVirtualHost(defaultVirtualHost.build());
    } catch (Exception e) {
      throw new Error(e);
    }
    server = sb.build();
  }
Exemplo n.º 2
0
  @Override
  protected void configureServer(ServerBuilder sb) throws Exception {
    sb.serviceUnder(
        "/jsp/",
        new JettyServiceBuilder()
            .handler(newWebAppContext())
            .configurator(s -> jettyBeans.addAll(s.getBeans()))
            .build()
            .decorate(LoggingService::new));

    sb.serviceUnder("/default/", new JettyServiceBuilder().handler(new DefaultHandler()).build());
  }