Malloy
Loading...
Searching...
No Matches
malloy::server::endpoint_http_files Class Reference

Endpoint for file serving. More...

#include <endpoint_http_files.hpp>

Inheritance diagram for malloy::server::endpoint_http_files:
Collaboration diagram for malloy::server::endpoint_http_files:

Public Member Functions

bool matches (const req_header_t &head) const override
handle_retr handle (const req_t &req, const http::connection_t &conn) const override
Public Member Functions inherited from malloy::server::endpoint_http
 endpoint_http (const endpoint_http &other)=default
 endpoint_http (endpoint_http &&other) noexcept=default
endpoint_http & operator= (const endpoint_http &rhs)=default
endpoint_http & operator= (endpoint_http &&rhs) noexcept=default
Public Member Functions inherited from malloy::server::endpoint
 endpoint (const endpoint &other)=default
 endpoint (endpoint &&other) noexcept=default
endpoint & operator= (const endpoint &rhs)=default
endpoint & operator= (endpoint &&rhs) noexcept=default

Public Attributes

std::string resource_base
std::filesystem::path base_path
std::string cache_control
write_func writer
Public Attributes inherited from malloy::server::endpoint_http
malloy::http::method method = malloy::http::method::unknown

Additional Inherited Members

Public Types inherited from malloy::server::endpoint_http
template<typename... Bodies>
using response_t = std::variant<malloy::http::response<Bodies>...>
template<typename... Bodies>
using writer_t = std::function<void(const boost::beast::http::request_header<>&, std::variant<malloy::http::response<Bodies>...>&&, const http::connection_t&)>
using handle_retr = std::optional<malloy::http::response<boost::beast::http::string_body>>
using req_header_t = boost::beast::http::request_header<>
using req_t = http::request_generator_t

Detailed Description

Endpoint for file serving.

Serves files at a resource path. The url path after the resource base is appended to a base path on the filesystem. e.g. /content/img.svg with a resource path of / and a base path of /var/www/content would result in the file at /var/www/content/content/img.svg being served.

Member Function Documentation

◆ handle()

handle_retr malloy::server::endpoint_http_files::handle ( const req_t & req,
const http::connection_t & conn ) const
inlinenodiscardoverridevirtual

Handle the request and return the corresponding response.

Parameters
reqThe request.
Returns
The response for the specified request.

Implements malloy::server::endpoint_http.

Here is the call graph for this function:

◆ matches()

bool malloy::server::endpoint_http_files::matches ( const req_header_t & req) const
inlinenodiscardoverridevirtual

Checks whether this endpoint would match the specified request.

The default implementation only checks for the matching method.

Parameters
reqThe request to check.
locationThe location to check for matching.
Returns
Whether this endpoint matches the request.

Reimplemented from malloy::server::endpoint_http.


The documentation for this class was generated from the following file: