magpie
Loading...
Searching...
No Matches
magpie::App< ContextType > Class Template Reference
Inheritance diagram for magpie::App< ContextType >:
Collaboration diagram for magpie::App< ContextType >:

Public Member Functions

 App (std::shared_ptr< ContextType > dataStore, AppConfig &&conf={}, std::optional< raven::SSLConfig > &&sslConfig=std::nullopt)
template<typename = std::enable_if<std::is_trivially_default_constructible_v<ContextType>>>
 App (AppConfig &&conf={}, std::optional< raven::SSLConfig > &&sslConfig=std::nullopt)
template<routing::FixedString path, Method::HttpMethod method>
routing::BaseRoute< ContextType > * route (const routing::RouteCallback< path, ContextType > &callback)
void run () override
void shutdown () override
uint16_t getPort ()
void sync ()
const routing::BaseRoutergetRouter () override
data::CommonDatagetContext () const override
void registerGlobalMiddlewares (const std::vector< std::shared_ptr< Middleware< ContextType > > > &middlewares)
Middlewares< ContextType > * getMiddlewaresAsPtr () override
Public Member Functions inherited from magpie::ContextApp< data::CommonData >
 ContextApp (AppConfig &&config)
void useNotFoundErrorHandler ()
void use500ErrorHandler ()
Public Member Functions inherited from magpie::BaseApp
 BaseApp (AppConfig &&config)
const AppConfiggetConfig ()

Additional Inherited Members

Public Attributes inherited from magpie::ContextApp< data::CommonData >
std::shared_ptr< StatusHandlerNotFound< ContextType > > notFoundErrorHandler
std::shared_ptr< StatusHandler500< ContextType > > errorHandler
Protected Attributes inherited from magpie::BaseApp
const AppConfig config

Member Function Documentation

◆ getContext()

template<data::IsCommonData ContextType = data::CommonData>
data::CommonData * magpie::App< ContextType >::getContext ( ) const
inlineoverridevirtual

Implements magpie::BaseApp.

◆ getMiddlewaresAsPtr()

template<data::IsCommonData ContextType = data::CommonData>
Middlewares< ContextType > * magpie::App< ContextType >::getMiddlewaresAsPtr ( )
inlineoverridevirtual

◆ getRouter()

template<data::IsCommonData ContextType = data::CommonData>
const routing::BaseRouter & magpie::App< ContextType >::getRouter ( )
inlineoverridevirtual

Implements magpie::BaseApp.

◆ route()

template<data::IsCommonData ContextType = data::CommonData>
template<routing::FixedString path, Method::HttpMethod method>
routing::BaseRoute< ContextType > * magpie::App< ContextType >::route ( const routing::RouteCallback< path, ContextType > & callback)
inline

Adds a route.

Each call to this method is only allowed to specify one HTTP method. This is because it's considered bad practice to support more than one HTTP method per function call. However, you can still get around this by calling the route function several times with the same function.

HTTP methods have distinct meanings per the standard. It's therefore arguably never appropriate to use the same handler for different methods. If you have code in common, instead of using the same handler, move that code into reusable modules.

Returns
A BaseRoute instance that can be used for some further configuration.

◆ run()

template<data::IsCommonData ContextType = data::CommonData>
void magpie::App< ContextType >::run ( )
inlineoverridevirtual

Implements magpie::BaseApp.

◆ shutdown()

template<data::IsCommonData ContextType = data::CommonData>
void magpie::App< ContextType >::shutdown ( )
inlineoverridevirtual

Implements magpie::BaseApp.


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