Malloy
Loading...
Searching...
No Matches
endpoint_http.hpp
1#pragma once
2
3#include "endpoint.hpp"
4#include "../http/connection_t.hpp"
5#include "../http/request_generator_t.hpp"
6#include "../../core/http/generator.hpp"
7#include "../../core/http/request.hpp"
8#include "../../core/http/response.hpp"
9#include "../../core/http/types.hpp"
10
11#include <functional>
12#include <optional>
13
14namespace malloy::server
15{
16
22 {
23 template<typename... Bodies>
24 using response_t = std::variant<malloy::http::response<Bodies>...>;
25
26 template<typename... Bodies>
27 using writer_t = std::function<void(const boost::beast::http::request_header<>&, std::variant<malloy::http::response<Bodies>...>&&, const http::connection_t&)>;
28
29 using handle_retr = std::optional<malloy::http::response<boost::beast::http::string_body>>;
30 using req_header_t = boost::beast::http::request_header<>;
31 using req_t = http::request_generator_t;
32
33 malloy::http::method method = malloy::http::method::unknown;
34
35 endpoint_http() = default;
36 endpoint_http(const endpoint_http& other) = default;
37 endpoint_http(endpoint_http&& other) noexcept = default;
38 ~endpoint_http() override = default;
39
40 endpoint_http& operator=(const endpoint_http& rhs) = default;
41 endpoint_http& operator=(endpoint_http&& rhs) noexcept = default;
42
52 [[nodiscard]]
53 virtual
54 bool matches(const req_header_t& req) const
55 {
56 return method == req.method();
57 }
58
65 [[nodiscard]]
66 virtual
67 handle_retr handle(const req_t& req, const http::connection_t& conn) const = 0;
68 };
69
70}
Definition: response.hpp:22
boost::beast::http::verb method
Definition: types.hpp:18
Definition: endpoint_http.hpp:22
virtual handle_retr handle(const req_t &req, const http::connection_t &conn) const =0
virtual bool matches(const req_header_t &req) const
Definition: endpoint_http.hpp:54
Definition: endpoint.hpp:10