|
|
template<typename... Ts> |
| | Crow (Ts &&... ts) |
| | Construct Crow with a subset of middleware.
|
| |
| template<typename Adaptor > |
| void | handle_upgrade (const request &req, response &res, Adaptor &&adaptor) |
| | Process an Upgrade request.
|
| |
|
std::unique_ptr< routing_handle_result > | handle_initial (request &req, response &res) |
| | Process only the method and URL of a request and provide a route (or an error response)
|
| |
|
void | handle (request &req, response &res, std::unique_ptr< routing_handle_result > &found) |
| | Process the fully parsed request and generate a response for it.
|
| |
|
void | handle_full (request &req, response &res) |
| | Process a fully parsed request from start to finish (primarily used for debugging)
|
| |
|
DynamicRule & | route_dynamic (const std::string &rule) |
| | Create a dynamic route using a rule (Use CROW_ROUTE instead)
|
| |
|
template<uint64_t Tag> |
| auto | route (const std::string &rule) -> typename std::invoke_result< decltype(&Router::new_rule_tagged< Tag >), Router, const std::string & >::type |
| | Create a route using a rule (Use CROW_ROUTE instead)
|
| |
| StaticRule & | route_static (const std::string &url) |
| | Create a static route to given url.
|
| |
| StaticRule & | static_file (std::string_view url, std::string_view internalPath) |
| | Creates a static route for given url to internalPath.
|
| |
|
CatchallRule & | catchall_route () |
| | Create a route for any requests without a proper route (Use CROW_CATCHALL_ROUTE instead)
|
| |
|
self_t & | websocket_max_payload (uint64_t max_payload) |
| | Set the default max payload size for websockets.
|
| |
|
uint64_t | websocket_max_payload () |
| | Get the default max payload size for websockets.
|
| |
|
self_t & | signal_clear () |
| |
|
self_t & | signal_add (int signal_number) |
| |
|
std::vector< int > | signals () |
| |
|
self_t & | port (std::uint16_t port) |
| | Set the port that Crow will handle requests on.
|
| |
|
std::uint16_t | port () const |
| | Get the port that Crow will handle requests on.
|
| |
|
void | address_is_bound () |
| | Set status variable to note that the address that Crow will handle requests on is bound.
|
| |
|
bool | is_bound () const |
| | Get whether address that Crow will handle requests on is bound.
|
| |
|
self_t & | timeout (std::uint8_t timeout) |
| | Set the connection timeout in seconds (default is 5)
|
| |
|
self_t & | server_name (std::string server_name) |
| | Set the server name included in the 'Server' HTTP response header. If set to an empty string, the header will be omitted by default.
|
| |
|
self_t & | bindaddr (std::string bindaddr) |
| | The IP address that Crow will handle requests on (default is 0.0.0.0)
|
| |
|
std::string | bindaddr () |
| | Get the address that Crow will handle requests on.
|
| |
|
self_t & | local_socket_path (std::string path) |
| | Disable tcp/ip and use unix domain socket instead.
|
| |
|
std::string | local_socket_path () |
| | Get the unix domain socket path.
|
| |
|
self_t & | multithreaded () |
| | Run the server on multiple threads using all available threads.
|
| |
|
self_t & | concurrency (unsigned int concurrency) |
| | Run the server on multiple threads using a specific number.
|
| |
|
std::uint16_t | concurrency () const |
| | Get the number of threads that server is using.
|
| |
| self_t & | loglevel (LogLevel level) |
| | Set the server's log level.
|
| |
| self_t & | stream_threshold (size_t threshold) |
| | Set the response body size (in bytes) beyond which Crow automatically streams responses (Default is 1MiB)
|
| |
|
size_t & | stream_threshold () |
| | Get the response body size (in bytes) beyond which Crow automatically streams responses.
|
| |
|
self_t & | register_blueprint (Blueprint &blueprint) |
| |
| template<typename Func > |
| self_t & | exception_handler (Func &&f) |
| | Set the function to call to handle uncaught exceptions generated in routes (Default generates error 500).
|
| |
|
std::function< void(crow::response &)> & | exception_handler () |
| |
|
template<typename Duration , typename Func > |
| self_t & | tick (Duration d, Func f) |
| | Set a custom duration and function to run on every tick.
|
| |
|
self_t & | use_compression (compression::algorithm algorithm) |
| |
|
compression::algorithm | compression_algorithm () |
| |
|
bool | compression_used () const |
| |
|
void | add_blueprint () |
| | Apply blueprints.
|
| |
|
void | add_static_dir () |
| | Go through the rules, upgrade them if possible, and add them to the list of rules.
|
| |
|
void | validate () |
| | A wrapper for validate() in the router.
|
| |
|
void | run () |
| | Run the server.
|
| |
| std::future< void > | run_async () |
| | Non-blocking version of run()
|
| |
|
void | stop () |
| | Stop the server.
|
| |
|
void | close_websockets () |
| |
|
void | add_websocket (std::shared_ptr< websocket::connection > conn) |
| |
|
void | remove_websocket (std::shared_ptr< websocket::connection > conn) |
| |
|
void | debug_print () |
| | Print the routing paths defined for each HTTP method.
|
| |
|
self_t & | ssl_file (const std::string &crt_filename, const std::string &key_filename) |
| | Use certificate and key files for SSL.
|
| |
|
self_t & | ssl_file (const std::string &pem_filename) |
| | Use .pem file for SSL.
|
| |
|
self_t & | ssl_chainfile (const std::string &crt_filename, const std::string &key_filename) |
| | Use certificate chain and key files for SSL.
|
| |
|
self_t & | ssl (asio::ssl::context &&ctx) |
| |
|
bool | ssl_used () const |
| |
|
template<typename T > |
| T::context & | get_context (const request &req) |
| |
|
template<typename T > |
| T & | get_middleware () |
| |
|
std::cv_status | wait_for_server_start (std::chrono::milliseconds wait_timeout=std::chrono::milliseconds(3000)) |
| | Wait until the server has properly started.
|
| |
template<typename... Middlewares>
class crow::Crow< Middlewares >
The main server application class.
Use crow::SimpleApp or crow::App<Middleware1, Middleware2, etc...> instead of directly instantiate this class.