3#include "endpoint_http.hpp"
4#include "../../core/http/request.hpp"
5#include "../../core/http/utils.hpp"
6#include "../../core/type_traits.hpp"
10namespace malloy::server
23 using write_func = writer_t<boost::beast::http::file_body, boost::beast::http::string_body>;
26 std::string resource_base;
27 std::filesystem::path base_path;
28 std::string cache_control;
33 bool matches(
const req_header_t& head)
const override
35 return malloy::http::resource_string(head).starts_with(resource_base);
39 handle_retr
handle(
const req_t& req,
const http::connection_t& conn)
const override
41 std::visit([
this, conn](
auto& gen) {
42 gen->template body<boost::beast::http::string_body>([
this, conn](
auto&& req) {
44 malloy::http::chop_resource(req_clone, resource_base);
48 std::visit([
this]<
typename Resp>(Resp& resp){ resp.set(malloy::http::field::cache_control, cache_control); }, resp);
51 writer(req, std::move(resp), conn);
static file_response file(const request< Body > &req, const std::filesystem::path &storage_base_path)
Definition: generator.hpp:114
Definition: request.hpp:19
Endpoint for file serving.
Definition: endpoint_http_files.hpp:22
bool matches(const req_header_t &head) const override
Definition: endpoint_http_files.hpp:33
handle_retr handle(const req_t &req, const http::connection_t &conn) const override
Definition: endpoint_http_files.hpp:39
Definition: endpoint_http.hpp:22