virthttp  0.0
libvirt http interface
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
HandlerMethods Struct Referenceabstract

#include <base.hpp>

Inheritance diagram for HandlerMethods:
HandlerContext DomainHandlers NetworkHandlers

Public Types

using Verbs = VerbList< boost::beast::http::verb::post, boost::beast::http::verb::get, boost::beast::http::verb::patch, boost::beast::http::verb::delete_ >
 

Public Member Functions

virtual DependsOutcome create (const rapidjson::Value &obj)=0
 
virtual DependsOutcome query (const rapidjson::Value &obj)=0
 
virtual DependsOutcome alter (const rapidjson::Value &obj)=0
 
virtual DependsOutcome vacuum (const rapidjson::Value &obj)=0
 
constexpr HandlerMethods (HandlerContext &hc) noexcept
 

Static Public Member Functions

static constexpr long verb_to_idx (boost::beast::http::verb v) noexcept
 

Static Public Attributes

static constexpr std::array methods = {&HandlerMethods::create, &HandlerMethods::query, &HandlerMethods::alter, &HandlerMethods::vacuum}
 

Additional Inherited Members

- Public Attributes inherited from HandlerContext
virt::Connectionconn
 the connection to perform libvirt operations through (plans to change to a vector) More...
 
JsonResjson_res
 the result of running the handlers to be sent to the client More...
 
const TargetParsertarget
 the incoming request's URI target More...
 
- Protected Member Functions inherited from HandlerContext
template<class... Args>
auto error (Args &&...args) const noexcept(noexcept(json_res.error(std::forward< Args >(args)...))) -> decltype(json_res.error(std::forward< Args >(args)...))
 
const auto fwd_err (bool fwd, int code)
 
const auto fwd_as_if_err (int code)
 

Detailed Description

Purely abstract base class for libvirt object-specific handlers

Intended to be used in a place where the compiler should definitely be able to de-virtualize

Member Typedef Documentation

using HandlerMethods::Verbs = VerbList<boost::beast::http::verb::post, boost::beast::http::verb::get, boost::beast::http::verb::patch, boost::beast::http::verb::delete_>

Array of HTTP verbs handled by the handler methods

Constructor & Destructor Documentation

constexpr HandlerMethods::HandlerMethods ( HandlerContext hc)
inlineexplicitnoexcept
Parameters
hcthe HandlerContext to use as a base

Member Function Documentation

virtual DependsOutcome HandlerMethods::alter ( const rapidjson::Value &  obj)
pure virtual

Performs the described modification on the associated libvirt object(s) Is the handler for HTTP PATCH

Parameters
[in]objthe HTTP request body, parsed as JSON
Returns
DependsOutcome::SUCCESS or DependsOutcome::FAILURE

Implemented in NetworkHandlers, and DomainHandlers.

virtual DependsOutcome HandlerMethods::create ( const rapidjson::Value &  obj)
pure virtual

Creates an associated libvirt object. Is the handler for HTTP POST

Parameters
[in]objthe HTTP request body, parsed as JSON
Returns
DependsOutcome::SUCCESS or DependsOutcome::FAILURE

Implemented in DomainHandlers, and NetworkHandlers.

virtual DependsOutcome HandlerMethods::query ( const rapidjson::Value &  obj)
pure virtual

Retrieves information about the associated libvirt object(s) Is the handler for HTTP GET

Parameters
[in]objthe HTTP request body, parsed as JSON
Returns
DependsOutcome::SUCCESS or DependsOutcome::FAILURE

Implemented in NetworkHandlers, and DomainHandlers.

virtual DependsOutcome HandlerMethods::vacuum ( const rapidjson::Value &  obj)
pure virtual

Removes the associated libvirt object(s) Is the handler for HTTP DELETE

Parameters
[in]objthe HTTP request body, parsed as JSON
Returns
DependsOutcome::SUCCESS or DependsOutcome::FAILURE

Implemented in NetworkHandlers, and DomainHandlers.

static constexpr long HandlerMethods::verb_to_idx ( boost::beast::http::verb  v)
inlinestaticnoexcept

Gives index of a given HTTP verb in Verbs, which can be used to access the associated handler in methods

Parameters
vthe HTTP verb
Returns
the index of the verb if found, -1 otherwise

Member Data Documentation

constexpr std::array HandlerMethods::methods = {&HandlerMethods::create, &HandlerMethods::query, &HandlerMethods::alter, &HandlerMethods::vacuum}
static

Array of the handler methods, with corresponding indices to the handled verb in Verbs


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