userver: userver/server/server_base.hpp Source File
Loading...
Searching...
No Matches
server_base.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/server_base.hpp
4/// @brief Transport-independent HTTP server contract.
5
6#include <string>
7#include <string_view>
8#include <vector>
9
10#include <userver/engine/task/task_processor_fwd.hpp>
11#include <userver/server/congestion_control/limiter.hpp>
12#include <userver/server/congestion_control/sensor.hpp>
13#include <userver/server/http/http_status.hpp>
14
15USERVER_NAMESPACE_BEGIN
16
17namespace server {
18
19struct ServerConfig;
20namespace handlers {
21class HttpHandlerBase;
22}
23
24/// @brief Transport-independent HTTP server capabilities used by handlers and congestion control.
25class ServerBase : public congestion_control::Limitee, public congestion_control::RequestsSource {
26public:
27 virtual ~ServerBase() = default;
28
29 /// @brief Return immutable defaults used when constructing handler configurations.
30 virtual const server::ServerConfig& GetConfig() const = 0;
31
32 /// @brief Return the common middleware pipeline for the selected endpoint.
33 virtual std::vector<std::string> GetCommonMiddlewares(bool is_monitor) const = 0;
34
35 /// @brief Return the endpoint default for the response hostname header.
36 virtual bool GetResponseHostnameDefault(bool is_monitor) const = 0;
37
38 /// @brief Register a fully constructed handler.
39 virtual void AddHandler(const server::handlers::HttpHandlerBase&, engine::TaskProcessor&) = 0;
40
41 /// @brief Configure the main endpoint's congestion-control rejection status.
42 virtual void SetRpsRatelimitStatusCode(server::http::HttpStatus status) = 0;
43};
44
45} // namespace server
46
47USERVER_NAMESPACE_END