Prometheus Client Library for Modern C++
Loading...
Searching...
No Matches
endpoint.h
1#pragma once
2
3#include <functional>
4#include <memory>
5#include <string>
6
7#include "CivetServer.h"
8#include "basic_auth.h"
9#include "prometheus/collectable.h"
10#include "prometheus/registry.h"
11
12namespace prometheus::detail {
13class MetricsHandler;
14
15class Endpoint {
16 public:
17 explicit Endpoint(CivetServer& server, std::string uri);
18 ~Endpoint();
19
20 Endpoint(const Endpoint&) = delete;
21 Endpoint(Endpoint&&) = delete;
22 Endpoint& operator=(const Endpoint&) = delete;
23 Endpoint& operator=(Endpoint&&) = delete;
24
25 void RegisterCollectable(const std::weak_ptr<Collectable>& collectable);
26 void RegisterAuth(
27 std::function<bool(const std::string&, const std::string&)> authCB,
28 const std::string& realm);
29 void RemoveCollectable(const std::weak_ptr<Collectable>& collectable);
30
31 const std::string& GetURI() const;
32
33 private:
34 CivetServer& server_;
35 const std::string uri_;
36 // registry for "meta" metrics about the endpoint itself
37 std::shared_ptr<Registry> endpoint_registry_;
38 std::unique_ptr<MetricsHandler> metrics_handler_;
39 std::unique_ptr<BasicAuthHandler> auth_handler_;
40};
41
42} // namespace prometheus::detail