Добавлен флаг debug.tempApi.enabled для временных debug API
This commit is contained in:
parent
bd0c3dba50
commit
5713287c84
@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
## 1) Подготовка
|
## 1) Подготовка
|
||||||
|
|
||||||
|
|
||||||
|
0. Убедись, что в `application.properties` включен параметр:
|
||||||
|
`debug.tempApi.enabled=true`
|
||||||
1. Создай файл `.debug-token` в корне проекта на основе `debug-token.example`.
|
1. Создай файл `.debug-token` в корне проекта на основе `debug-token.example`.
|
||||||
2. В `.debug-token` должна быть одна строка: секретный токен.
|
2. В `.debug-token` должна быть одна строка: секретный токен.
|
||||||
3. Перезапусти сервер.
|
3. Перезапусти сервер.
|
||||||
|
|||||||
@ -3,21 +3,34 @@ package server.debug;
|
|||||||
import jakarta.servlet.Servlet;
|
import jakarta.servlet.Servlet;
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import utils.config.AppConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Регистрирует HTTP debug endpoints.
|
* Регистрирует HTTP debug endpoints.
|
||||||
*/
|
*/
|
||||||
public final class DebugApiConfigurator {
|
public final class DebugApiConfigurator {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(DebugApiConfigurator.class);
|
||||||
|
private static final String CFG_DEBUG_API_ENABLED = "debug.tempApi.enabled";
|
||||||
|
|
||||||
private DebugApiConfigurator() {
|
private DebugApiConfigurator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(ServletContextHandler context) {
|
public static void register(ServletContextHandler context) {
|
||||||
|
boolean enabled = AppConfig.getInstance().getBoolean(CFG_DEBUG_API_ENABLED, false);
|
||||||
|
if (!enabled) {
|
||||||
|
log.warn("⚠️ Debug API отключены настройкой {}=false", CFG_DEBUG_API_ENABLED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DebugTokenProvider tokenProvider = DebugTokenProvider.loadFromProjectRoot();
|
DebugTokenProvider tokenProvider = DebugTokenProvider.loadFromProjectRoot();
|
||||||
|
|
||||||
addServlet(context, new DebugClientsServlet(tokenProvider), "/debug/ws/clients");
|
addServlet(context, new DebugClientsServlet(tokenProvider), "/debug/ws/clients");
|
||||||
addServlet(context, new DebugConnectServlet(tokenProvider), "/debug/ws/connect");
|
addServlet(context, new DebugConnectServlet(tokenProvider), "/debug/ws/connect");
|
||||||
addServlet(context, new DebugLogsServlet(tokenProvider), "/debug/ws/logs");
|
addServlet(context, new DebugLogsServlet(tokenProvider), "/debug/ws/logs");
|
||||||
|
log.info("✅ Debug API включены настройкой {}=true", CFG_DEBUG_API_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addServlet(ServletContextHandler context, Servlet servlet, String path) {
|
private static void addServlet(ServletContextHandler context, Servlet servlet, String path) {
|
||||||
|
|||||||
@ -17,3 +17,11 @@ server.info.extraInfo=
|
|||||||
webpush.vapid.public=BOdoWZndZRaNe9kyUFsJ5-xEfFABXNKennAKg15Z7ycAwUIQ7yDV_sIWWYJCwJriN4g9oU-CyJPrn1U6lfxuDbI
|
webpush.vapid.public=BOdoWZndZRaNe9kyUFsJ5-xEfFABXNKennAKg15Z7ycAwUIQ7yDV_sIWWYJCwJriN4g9oU-CyJPrn1U6lfxuDbI
|
||||||
webpush.vapid.private=3hCt7XxTvLzuoxinjT5QcKRQEBnGZHXn8ZilU31RPNE
|
webpush.vapid.private=3hCt7XxTvLzuoxinjT5QcKRQEBnGZHXn8ZilU31RPNE
|
||||||
webpush.vapid.subject=mailto:admin@shine.local
|
webpush.vapid.subject=mailto:admin@shine.local
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Временные debug HTTP API для тестирования соединений
|
||||||
|
# true - endpoint'ы /debug/ws/* включены (только при наличии .debug-token)
|
||||||
|
# false - endpoint'ы /debug/ws/* полностью отключены
|
||||||
|
# Если параметр отсутствует, по умолчанию считается false
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
debug.tempApi.enabled=true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user