roar
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
request_listener.hpp File Reference
#include <roar/routing/proto_route.hpp>
#include <roar/utility/overloaded.hpp>
#include <roar/literals/regex.hpp>
#include <roar/session/session.hpp>
#include <roar/routing/flexible_provider.hpp>
#include <roar/request.hpp>
#include <boost/beast/http/verb.hpp>
#include <boost/beast/http/empty_body.hpp>
#include <boost/describe/class.hpp>
#include <string_view>
#include <optional>
#include <variant>
#include <regex>
#include <string>
#include <filesystem>
Include dependency graph for request_listener.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Roar::ServeOptions< RequestListenerT >
 
struct  Roar::FileAndStatus
 
struct  Roar::RouteInfo< RequestListenerT >
 This class is what is used in ROAR_GET, ROAR_PUT, ... requests All options you can set for routes behind these macros are part of this object. More...
 
struct  Roar::ServeInfo< RequestListenerT >
 

Namespaces

namespace  Roar
 

Macros

#define ROUTE_INFO_COMMON()
 
#define ROAR_MAKE_LISTENER(ListenerType)   using this_type = ListenerType
 Necessary to make pointer to members.
 
#define ROAR_ROUTE_I(HandlerName, DefaultVerb)
 
#define ROAR_SERVE(HandlerName)
 
#define ROAR_ROUTE(HandlerName)   ROAR_ROUTE_I(HandlerName, get)
 Define a route. route.
 
#define ROAR_GET(HandlerName)   ROAR_ROUTE_I(HandlerName, get)
 Define route for GET, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})
 
#define ROAR_POST(HandlerName)   ROAR_ROUTE_I(HandlerName, post)
 Define route for POST, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})
 
#define ROAR_PUT(HandlerName)   ROAR_ROUTE_I(HandlerName, put)
 Define route for PUT, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})
 
#define ROAR_OPTIONS(HandlerName)   ROAR_ROUTE_I(HandlerName, options)
 Define route for OPTIONS, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})
 
#define ROAR_TRACE(HandlerName)   ROAR_ROUTE_I(HandlerName, trace)
 Define route for TRACE, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})
 
#define ROAR_HEAD(HandlerName)   ROAR_ROUTE_I(HandlerName, head)
 Define route for HEAD, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})
 
#define ROAR_DELETE(HandlerName)   ROAR_ROUTE_I(HandlerName, delete_)
 Define route for DELETE, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})
 

Typedefs

template<typename RequestListenerT >
using Roar::HandlerType = void(RequestListenerT::*)(Session &, Request< boost::beast::http::empty_body > &&)
 
template<typename RequestListenerT >
using Roar::ServeHandlerType = ServeDecision(RequestListenerT::*)(Session &, Request< boost::beast::http::empty_body > const &, FileAndStatus const &, ServeOptions< RequestListenerT > &options)
 

Enumerations

enum class  Roar::ServeDecision { Roar::Continue , Roar::Deny , Roar::Handled }
 
enum class  Roar::RoutePathType { Roar::Unspecified , Roar::RegularString , Roar::Regex , Roar::ServedDirectory }
 

Functions

template<typename RequestListenerT >
auto Roar::extendRouteInfo (RouteInfo< RequestListenerT > info, HandlerType< RequestListenerT > handler)
 
template<typename RequestListenerT >
auto Roar::extendRouteInfoForServe (ServeInfo< RequestListenerT > info, ServeHandlerType< RequestListenerT > handler)
 

Macro Definition Documentation

◆ ROAR_DELETE

#define ROAR_DELETE (   HandlerName)    ROAR_ROUTE_I(HandlerName, delete_)

Define route for DELETE, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})

◆ ROAR_GET

#define ROAR_GET (   HandlerName)    ROAR_ROUTE_I(HandlerName, get)

Define route for GET, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})

◆ ROAR_HEAD

#define ROAR_HEAD (   HandlerName)    ROAR_ROUTE_I(HandlerName, head)

Define route for HEAD, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})

◆ ROAR_MAKE_LISTENER

#define ROAR_MAKE_LISTENER (   ListenerType)    using this_type = ListenerType

Necessary to make pointer to members.

◆ ROAR_OPTIONS

#define ROAR_OPTIONS (   HandlerName)    ROAR_ROUTE_I(HandlerName, options)

Define route for OPTIONS, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})

◆ ROAR_POST

#define ROAR_POST (   HandlerName)    ROAR_ROUTE_I(HandlerName, post)

Define route for POST, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})

◆ ROAR_PUT

#define ROAR_PUT (   HandlerName)    ROAR_ROUTE_I(HandlerName, put)

Define route for PUT, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})

◆ ROAR_ROUTE

#define ROAR_ROUTE (   HandlerName)    ROAR_ROUTE_I(HandlerName, get)

Define a route. route.

◆ ROAR_ROUTE_I

#define ROAR_ROUTE_I (   HandlerName,
  DefaultVerb 
)
Value:
void HandlerName(Roar::Session& session, Roar::Request<boost::beast::http::empty_body>&& request); \
inline static const auto roar_##HandlerName = Roar::extendRouteInfo( \
Roar::RouteInfo<this_type>{.verb = boost::beast::http::verb::DefaultVerb}, &this_type::HandlerName)
This class extends the boost::beast::http::request<BodyT> with additional convenience.
Definition request.hpp:52
Definition session.hpp:41
auto extendRouteInfo(RouteInfo< RequestListenerT > info, HandlerType< RequestListenerT > handler)
Definition request_listener.hpp:146
This class is what is used in ROAR_GET, ROAR_PUT, ... requests All options you can set for routes beh...
Definition request_listener.hpp:120
std::optional< boost::beast::http::verb > verb
What verb for this route?
Definition request_listener.hpp:124

◆ ROAR_SERVE

#define ROAR_SERVE (   HandlerName)
Value:
Roar::ServeDecision HandlerName( \
Roar::Session& session, \
Roar::FileAndStatus const& fileAndStatus, \
inline static const auto roar_##HandlerName = \
Roar::extendRouteInfoForServe(Roar::ServeInfo<this_type>{}, &this_type::HandlerName)
ServeDecision
Definition request_listener.hpp:28
Definition request_listener.hpp:92
Definition request_listener.hpp:135
Definition request_listener.hpp:58

◆ ROAR_TRACE

#define ROAR_TRACE (   HandlerName)    ROAR_ROUTE_I(HandlerName, trace)

Define route for TRACE, others can be accessed via ROAR_ROUTE({.verb = ..., .path = ""})

◆ ROUTE_INFO_COMMON

#define ROUTE_INFO_COMMON ( )
Value:
char const* path = nullptr; \
RouteOptions routeOptions = { \
.allowUnsecure = false, \
.expectUpgrade = false, \
.cors = std::nullopt, \
};