Malloy
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
malloy::http::generator Class Reference

#include <generator.hpp>

Public Member Functions

 generator ()=default
 
 generator (const generator &other)=delete
 
 generator (generator &&other)=delete
 
virtual ~generator ()=default
 
generatoroperator= (const generator &rhs)=delete
 
generatoroperator= (generator &&rhs)=delete
 

Static Public Member Functions

static response ok ()
 
static response redirect (status code, std::string_view location)
 
static response bad_request (std::string_view reason)
 
static response not_found (std::string_view resource)
 
static response server_error (std::string_view what)
 
template<malloy::http::concepts::body Body>
static file_response file (const request< Body > &req, const std::filesystem::path &storage_base_path)
 
static file_response file (const std::filesystem::path &storage_path, std::string_view rel_path)
 

Detailed Description

A generator for HTTP responses.

Constructor & Destructor Documentation

◆ generator()

malloy::http::generator::generator ( )
default

Default constructor.

◆ ~generator()

virtual malloy::http::generator::~generator ( )
virtualdefault

Destructor

Member Function Documentation

◆ bad_request()

response generator::bad_request ( std::string_view  reason)
static

Construct a 400 error.

Parameters
reasonAn explanation of why this request is considered a bad one.
Returns
The response.

◆ file() [1/2]

static file_response malloy::http::generator::file ( const request< Body > &  req,
const std::filesystem::path &  storage_base_path 
)
inlinestatic

Construct a file response.

Parameters
reqThe request to be responded to.
storage_base_pathThe base path to the local filesystem.
Returns
The response.
Here is the call graph for this function:

◆ file() [2/2]

generator::file_response generator::file ( const std::filesystem::path &  storage_path,
std::string_view  rel_path 
)
static

Construct a file response.

Parameters
storage_pathThe base path to the local filesystem.
rel_pathThe file being requested relative to the storage_path.
Returns
The response.
Here is the call graph for this function:

◆ not_found()

response generator::not_found ( std::string_view  resource)
static

Construct a 404 error.

Parameters
resourceThe resource that was being requested.
Returns
The response.

◆ ok()

response generator::ok ( )
static

Construct a 200 response.

◆ redirect()

response generator::redirect ( status  code,
std::string_view  location 
)
static

Construct a 3xx response.

Parameters
codeThe HTTP status code. Must be a 3xx status code.
locationThe location to redirect to.
Returns
The response.
Here is the call graph for this function:

◆ server_error()

response generator::server_error ( std::string_view  what)
static

Construct a 500 error.

Parameters
whatAn optional error message.
Returns
The response.

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