diff options
author | Alexey Efimov <xeno@prnwatch.com> | 2022-05-17 11:34:57 +0300 |
---|---|---|
committer | Alexey Efimov <xeno@prnwatch.com> | 2022-05-17 11:34:57 +0300 |
commit | 742718e4953ed9e9f897f5194871fc7cec65caa3 (patch) | |
tree | 6501c24969779138b433d19606a22791742e38b9 /library/cpp/monlib/service/pages | |
parent | 1e1dfc1b3545147948cc2190bb15161f630507e9 (diff) | |
download | ydb-742718e4953ed9e9f897f5194871fc7cec65caa3.tar.gz |
add http-mon via ic proxy KIKIMR-14742
ref:b3a758f33f4578f7f8ce2e822783faf41a5ab6cd
Diffstat (limited to 'library/cpp/monlib/service/pages')
-rw-r--r-- | library/cpp/monlib/service/pages/index_mon_page.cpp | 33 | ||||
-rw-r--r-- | library/cpp/monlib/service/pages/index_mon_page.h | 5 | ||||
-rw-r--r-- | library/cpp/monlib/service/pages/mon_page.h | 4 |
3 files changed, 42 insertions, 0 deletions
diff --git a/library/cpp/monlib/service/pages/index_mon_page.cpp b/library/cpp/monlib/service/pages/index_mon_page.cpp index 1d3d6dac37..de2a5a058c 100644 --- a/library/cpp/monlib/service/pages/index_mon_page.cpp +++ b/library/cpp/monlib/service/pages/index_mon_page.cpp @@ -106,6 +106,39 @@ IMonPage* TIndexMonPage::FindPage(const TString& relativePath) { } } +IMonPage* TIndexMonPage::FindPageByAbsolutePath(const TString& absolutePath) { + TIndexMonPage* page = this; + TString path = absolutePath; + if (path.StartsWith("/")) { + path.erase(0, 1); + } + while (!path.empty()) { + TString tryPath = path; + while (!tryPath.empty()) { + IMonPage* found = page->FindPage(tryPath); + if (found == nullptr) { + size_t slash = tryPath.find_last_of('/'); + if (slash == TString::npos) { + return nullptr; + } + tryPath.resize(slash); + } else { + if (tryPath.size() == path.size()) { + return found; + } + if (found->IsIndex()) { + path = path.substr(tryPath.size() + 1); + page = static_cast<TIndexMonPage*>(found); + break; + } else { + return found; + } + } + } + } + return nullptr; +} + TIndexMonPage* TIndexMonPage::FindIndexPage(const TString& relativePath) { return VerifyDynamicCast<TIndexMonPage*>(FindPage(relativePath)); } diff --git a/library/cpp/monlib/service/pages/index_mon_page.h b/library/cpp/monlib/service/pages/index_mon_page.h index bf514a3105..af96bcd2b9 100644 --- a/library/cpp/monlib/service/pages/index_mon_page.h +++ b/library/cpp/monlib/service/pages/index_mon_page.h @@ -18,6 +18,10 @@ namespace NMonitoring { ~TIndexMonPage() override { } + bool IsIndex() const override { + return true; + } + void Output(IMonHttpRequest& request) override; void OutputIndexPage(IMonHttpRequest& request); virtual void OutputIndex(IOutputStream& out, bool pathEndsWithSlash); @@ -30,6 +34,7 @@ namespace NMonitoring { IMonPage* FindPage(const TString& relativePath); TIndexMonPage* FindIndexPage(const TString& relativePath); + IMonPage* FindPageByAbsolutePath(const TString& absolutePath); void SortPages(); void ClearPages(); diff --git a/library/cpp/monlib/service/pages/mon_page.h b/library/cpp/monlib/service/pages/mon_page.h index 136647e5be..215b58f0ae 100644 --- a/library/cpp/monlib/service/pages/mon_page.h +++ b/library/cpp/monlib/service/pages/mon_page.h @@ -61,6 +61,10 @@ namespace NMonitoring { return !Title.empty(); } + virtual bool IsIndex() const { + return false; + } + virtual void Output(IMonHttpRequest& request) = 0; }; |