virthttp  0.0
libvirt http interface
hdl_ctx.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <string>
3 #include "json_utils.hpp"
4 #include "urlparser.hpp"
5 #include "virt_wrap.hpp"
6 
15 
16  protected:
21  template <class... Args>
22  auto error(Args&&... args) const noexcept(noexcept(json_res.error(std::forward<Args>(args)...)))
23  -> decltype(json_res.error(std::forward<Args>(args)...)) {
24  return json_res.error(std::forward<Args>(args)...);
25  };
26 
27  const auto fwd_err(bool fwd, int code) {
28  if (!fwd)
29  error(code);
30  return fwd;
31  };
32  const auto fwd_as_if_err(int code) {
33  return [&, code](const auto& arg) { return fwd_err(static_cast<bool>(arg), code); };
34  };
35 };
void error(int code)
Definition: json_utils.hpp:57
STL namespace.
Definition: Connection.hpp:47
const TargetParser & target
the incoming request&#39;s URI target
Definition: hdl_ctx.hpp:14
Definition: json_utils.hpp:21
virt::Connection & conn
the connection to perform libvirt operations through (plans to change to a vector) ...
Definition: hdl_ctx.hpp:12
Definition: hdl_ctx.hpp:11
JsonRes & json_res
the result of running the handlers to be sent to the client
Definition: hdl_ctx.hpp:13
const auto fwd_as_if_err(int code)
Definition: hdl_ctx.hpp:32
const auto fwd_err(bool fwd, int code)
Definition: hdl_ctx.hpp:27
Definition: urlparser.hpp:36
auto error(Args &&...args) const noexcept(noexcept(json_res.error(std::forward< Args >(args)...))) -> decltype(json_res.error(std::forward< Args >(args)...))
Definition: hdl_ctx.hpp:22