3#include "../response.hpp"
4#include "../request.hpp"
5#include "../../error.hpp"
23 template<
bool isRequest>
28 using value_type = boost::beast::http::file_body::value_type;
29 using header_type = boost::beast::http::header<isRequest>;
30 using setup_handler_t = std::function<void(
const header_type&, value_type&)>;
49 setup{ std::move(setup_) }
76 const std::filesystem::path& location,
78 boost::beast::file_mode mode
81 return basic_file{ [location, mode, on_error = std::move(on_error)](
auto&&,
auto& body) {
82 boost::beast::error_code ec;
83 body.
open(location.string().c_str(), mode, ec);
90 std::variant<boost::beast::http::file_body>
91 body_for(
const header_type&)
const
97 setup_body(
const header_type& h, value_type& body)
const
104 using file_request = basic_file<true>;
105 using file_response = basic_file<false>;
Definition: request.hpp:19
Definition: response.hpp:22
Contains the filter types bundled with malloy.
Definition: controller.hpp:31
boost::beast::error_code error_code
Error code used to signify errors without throwing. Truthy means it holds an error.
Definition: error.hpp:9
Writes the contents of a message to disk.
Definition: file.hpp:25
basic_file(setup_handler_t setup_)
Construct with a setup handler.
Definition: file.hpp:48
static basic_file open(const std::filesystem::path &location, std::function< void(malloy::error_code)> on_error, boost::beast::file_mode mode)
Create a version of the filter that writes/reads the specified file.
Definition: file.hpp:75
basic_file(basic_file &&) noexcept=default
basic_file()=default
Default ctor.
setup_handler_t setup
Definition: file.hpp:35