Malloy
Toggle main menu visibility
Loading...
Searching...
No Matches
lib
malloy
core
http
generator.hpp
1
#pragma once
2
3
#include "response.hpp"
4
#include "request.hpp"
5
#include "type_traits.hpp"
6
#include "types.hpp"
7
#include "utils.hpp"
8
9
#include <filesystem>
10
#include <string_view>
11
#include <variant>
12
13
namespace
malloy::http
14
{
15
21
class
generator
22
{
29
using
file_response = std::variant<response<boost::beast::http::file_body>,
response<boost::beast::http::string_body>
>;
30
31
public
:
35
generator
() =
default
;
36
37
generator
(
const
generator
& other) =
delete
;
38
generator
(
generator
&& other) =
delete
;
39
43
virtual
44
~generator
() =
default
;
45
46
// Operators
47
generator
& operator=(
const
generator
& rhs) =
delete
;
48
generator
& operator=(
generator
&& rhs) =
delete
;
49
53
[[nodiscard]]
54
static
55
response<>
56
ok
();
57
65
[[nodiscard]]
66
static
67
response<>
68
redirect
(
status
code, std::string_view location);
69
76
[[nodiscard]]
77
static
78
response<>
79
bad_request
(std::string_view reason);
80
87
[[nodiscard]]
88
static
89
response<>
90
not_found
(std::string_view resource);
91
98
[[nodiscard]]
99
static
100
response<>
101
server_error
(std::string_view what);
102
110
template
<malloy::http::concepts::body Body>
111
[[nodiscard]]
112
static
113
file_response
114
file
(
const
request<Body>
& req,
const
std::filesystem::path& storage_base_path)
115
{
116
return
file
(storage_base_path, malloy::http::resource_string(req));
117
}
118
126
[[nodiscard]]
127
static
128
file_response
129
file
(
const
std::filesystem::path& storage_path, std::string_view rel_path);
130
};
131
132
}
malloy::http::generator::redirect
static response redirect(status code, std::string_view location)
Definition
generator.cpp:17
malloy::http::generator::file
static file_response file(const request< Body > &req, const std::filesystem::path &storage_base_path)
Definition
generator.hpp:114
malloy::http::generator::bad_request
static response bad_request(std::string_view reason)
Definition
generator.cpp:27
malloy::http::generator::not_found
static response not_found(std::string_view resource)
Definition
generator.cpp:37
malloy::http::generator::ok
static response ok()
Definition
generator.cpp:9
malloy::http::generator::generator
generator()=default
malloy::http::generator::~generator
virtual ~generator()=default
malloy::http::generator::server_error
static response server_error(std::string_view what)
Definition
generator.cpp:47
malloy::http::request
Definition
request.hpp:19
malloy::http::response
Definition
response.hpp:22
malloy::http
Definition
cookie.hpp:8
malloy::http::status
boost::beast::http::status status
Definition
types.hpp:23
Generated by
1.18.0