aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/net/http/state_api.h
blob: 9d4b9faf1142c5e9431e4c0ff3765ad95c02a48b (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "json_get_handler.h"
#include "health_producer.h"
#include "metrics_producer.h"
#include "component_config_producer.h"
#include <memory>
#include "json_handler_repo.h"

namespace vespalib {

/**
 * This class uses the underlying producer interfaces passed to the
 * constructor to implement the 'state' REST API. The get function is
 * a simple abstraction of a GET request returning json and can be
 * wired into the HttpServer or called directly.
 **/
class StateApi : public JsonGetHandler
{
private:
    const HealthProducer &_healthProducer;
    MetricsProducer &_metricsProducer;
    ComponentConfigProducer &_componentConfigProducer;
    JsonHandlerRepo _handler_repo;

public:
    StateApi(const HealthProducer &hp,
             MetricsProducer &mp,
             ComponentConfigProducer &ccp);
    ~StateApi() override;
    Response get(const vespalib::string &host,
                 const vespalib::string &path,
                 const std::map<vespalib::string,vespalib::string> &params,
                 const net::ConnectionAuthContext &auth_ctx) const override;
    JsonHandlerRepo &repo() { return _handler_repo; }
};

} // namespace vespalib