aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/net/http/generic_state_handler.h
blob: e602d79eb6a7db8f99760f33c7013b4eab2c1866 (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
// 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 "state_explorer.h"
#include <vespa/vespalib/stllike/string.h>
#include <vector>
#include <map>

namespace vespalib {

/**
 * An implementation of the json get handler interface that exposes
 * the state represented by the given state explorer as a browsable
 * REST sub-API located below the given root path.
 **/
class GenericStateHandler : public JsonGetHandler
{
private:
    std::vector<vespalib::string> _root;
    const StateExplorer &_state;

public:
    GenericStateHandler(const vespalib::string &root_path, const StateExplorer &state);
    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;
};

} // namespace vespalib