use of com.hotels.styx.admin.handlers.VersionTextHandler in project styx by ExpediaGroup.
the class AdminServerBuilder method adminEndpoints.
private HttpHandler adminEndpoints(StyxConfig styxConfig, StartupConfig startupConfig) {
Optional<Duration> metricsCacheExpiration = styxConfig.adminServerConfig().metricsCacheExpiration();
AdminHttpRouter httpRouter = new AdminHttpRouter();
httpRouter.aggregate("/", new IndexHandler(indexLinkPaths(styxConfig)));
httpRouter.aggregate("/version.txt", new VersionTextHandler(styxConfig.versionFiles(startupConfig)));
httpRouter.aggregate("/admin", new IndexHandler(indexLinkPaths(styxConfig)));
httpRouter.aggregate("/admin/uptime", new UptimeHandler(environment.meterRegistry()));
httpRouter.aggregate("/admin/ping", new PingHandler());
httpRouter.aggregate("/admin/threads", new ThreadsHandler());
httpRouter.aggregate("/admin/current_requests", new CurrentRequestsHandler(CurrentRequestTracker.INSTANCE));
MetricsHandler metricsHandler = new MetricsHandler(environment.metricRegistry(), metricsCacheExpiration);
httpRouter.aggregate("/admin/metrics", metricsHandler);
httpRouter.aggregate("/admin/metrics/", metricsHandler);
httpRouter.aggregate("/admin/configuration", new StyxConfigurationHandler(configuration));
httpRouter.aggregate("/admin/jvm", new JVMMetricsHandler(environment.metricRegistry(), metricsCacheExpiration));
httpRouter.aggregate("/admin/configuration/logging", new LoggingConfigurationHandler(startupConfig.logConfigLocation()));
httpRouter.aggregate("/admin/configuration/startup", new StartupConfigHandler(startupConfig));
RoutingObjectHandler routingObjectHandler = new RoutingObjectHandler(routeDatabase, routingObjectFactoryContext);
httpRouter.aggregate("/admin/routing", routingObjectHandler);
httpRouter.aggregate("/admin/routing/", routingObjectHandler);
ServiceProviderHandler serviceProvideHandler = new ServiceProviderHandler(providerDatabase);
httpRouter.aggregate("/admin/service/providers", serviceProvideHandler);
httpRouter.aggregate("/admin/service/provider/", serviceProvideHandler);
if (configVersion(styxConfig) == ROUTING_CONFIG_V1) {
httpRouter.aggregate("/admin/dashboard/data.json", dashboardDataHandler(styxConfig));
httpRouter.aggregate("/admin/dashboard/", new ClassPathResourceHandler("/admin/dashboard/"));
}
// Replace them in the backwards compatibility mode only.
// Remove altogether when Routing Engine is enabled:
httpRouter.aggregate("/admin/origins/status", new OriginsInventoryHandler(environment.eventBus()));
httpRouter.aggregate("/admin/configuration/origins", new OriginsHandler(backendServicesRegistry));
httpRouter.aggregate("/admin/tasks/origins/reload", new HttpMethodFilteringHandler(POST, new OriginsReloadCommandHandler(backendServicesRegistry)));
httpRouter.aggregate("/admin/tasks/origins", new HttpMethodFilteringHandler(POST, new OriginsCommandHandler(environment.eventBus())));
httpRouter.aggregate("/admin/tasks/plugin/", new PluginToggleHandler(environment.plugins()));
// Plugins Handler
environment.plugins().forEach(namedPlugin -> {
extensionEndpoints("plugins", namedPlugin.name(), namedPlugin.adminInterfaceHandlers()).forEach(route -> httpRouter.stream(route.path(), route.handler()));
});
httpRouter.aggregate("/admin/plugins", new PluginListHandler(environment.plugins()));
ProviderRoutingHandler providerHandler = new ProviderRoutingHandler("/admin/providers", providerDatabase);
httpRouter.aggregate("/admin/providers", providerHandler);
httpRouter.aggregate("/admin/providers/", providerHandler);
ProviderRoutingHandler serverHandler = new ProviderRoutingHandler("/admin/servers", serverDatabase);
httpRouter.aggregate("/admin/servers", serverHandler);
httpRouter.aggregate("/admin/servers/", serverHandler);
Optional<PrometheusMeterRegistry> optPrometheus = Optional.ofNullable(findRegistry(environment.meterRegistry().micrometerRegistry(), PrometheusMeterRegistry.class));
if (optPrometheus.isPresent()) {
httpRouter.aggregate("/metrics", new PrometheusHandler(optPrometheus.get()));
} else {
LOG.warn("No PrometheusMeterRegistry present, so we cannot publish to prometheus.");
}
return httpRouter;
}
Aggregations