public AdminServer()

in iep-admin/src/main/java/com/netflix/iep/admin/AdminServer.java [64:97]


  public AdminServer(AdminConfig config, Map<String, Object> endpoints)
      throws IOException {
    this.config = config;

    InetSocketAddress address = resolve(config.listenOn(), config.port());
    this.server = HttpServer.create(address, config.backlog());

    TreeSet<String> paths = new TreeSet<>(endpoints.keySet());
    for (String path : paths.descendingSet()) {
      Object obj = endpoints.get(path);
      HttpEndpoint endpoint = (obj instanceof HttpEndpoint)
          ? (HttpEndpoint) obj
          : new BasicHttpEndpoint(obj);
      createContext(path, new RequestHandler(path, endpoint));
    }

    SortedSet<String> resources = paths.stream()
        .map(p -> p.substring(1))
        .collect(Collectors.toCollection(TreeSet::new));
    resources.add("resources");
    createContext("/resources",
        new RequestHandler("/resources", new ResourcesEndpoint(resources)));

    StaticResourceHandler staticHandler = new StaticResourceHandler(
        Thread.currentThread().getContextClassLoader(),
        Collections.singletonMap("/ui", "static/index.html"));
    createContext("/static", staticHandler);
    createContext("/ui", staticHandler);

    createContext("/", new DefaultHandler(config));

    server.start();
    LOGGER.info("started on port {}", config.port());
  }