aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/service/pages/index_mon_page.h
blob: 0aaf826d4694de9dabfa9849570c15b73fdca252 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include "mon_page.h"

#include <list>

namespace NMonitoring {
    struct TIndexMonPage: public IMonPage {
        TMutex Mtx;
        using TPages = std::list<TMonPagePtr>;
        TPages Pages; // a list of pages to maintain specific order
        using TPagesByPath = THashMap<TString, TPages::iterator>;
        TPagesByPath PagesByPath;

        TIndexMonPage(const TString& path, const TString& title)
            : IMonPage(path, title)
        {
        }

        ~TIndexMonPage() override {
        }

        bool IsIndex() const override {
            return true;
        }

        void Output(IMonHttpRequest& request) override;
        void OutputIndexPage(IMonHttpRequest& request);
        virtual void OutputIndex(IOutputStream& out, bool pathEndsWithSlash);
        virtual void OutputCommonJsCss(IOutputStream& out);
        void OutputHead(IOutputStream& out);
        void OutputBody(IMonHttpRequest& out);

        void Register(TMonPagePtr page);
        TIndexMonPage* RegisterIndexPage(const TString& path, const TString& title);

        IMonPage* FindPage(const TString& relativePath);
        TIndexMonPage* FindIndexPage(const TString& relativePath);
        IMonPage* FindPageByAbsolutePath(const TString& absolutePath);

        void SortPages();
        void ClearPages();
    };

}