# HttpConnectionHandler.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/web/server/HttpConnectionHandler.hpp"
# HttpConnectionHandler
Simple ConnectionHandler (oatpp::network::ConnectionHandler) for handling HTTP communication.
Will create one thread per each connection to handle communication.
namespace oatpp { namespace web { namespace server {
class HttpConnectionHandler : public base::Countable, public network::ConnectionHandler, public HttpProcessor::TaskProcessingListener {}
}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | HttpConnectionHandler | Multiple implementations:
|
std::shared_ptr<HttpConnectionHandler> | createShared | Create shared HttpConnectionHandler. |
void | setErrorHandler | Set root error handler for all requests coming through this Connection Handler. |
void | addRequestInterceptor | Add request interceptor. Request interceptors are called before routing happens. |
void | addResponseInterceptor | Add response interceptor. |
void | handleConnection | Implementation of oatpp::network::ConnectionHandler::handleConnection(). |
void | stop | Tell all worker threads to exit when done. |
v_uint64 | getConnectionsCount | Get connections count. |
# HttpConnectionHandler::HttpConnectionHandler
- Constructor.
- @param components - oatpp::web::server::HttpProcessor::Components.
HttpConnectionHandler(const std::shared_ptr<HttpProcessor::Components>& components)
- Constructor.
- @param router - oatpp::web::server::HttpRouter to route incoming requests.
HttpConnectionHandler(const std::shared_ptr<HttpRouter>& router) : HttpConnectionHandler(std::make_shared<HttpProcessor::Components>(router))
- Constructor.
- @param router - oatpp::web::server::HttpRouter to route incoming requests.
- @param config - oatpp::web::server::HttpProcessor::Config.
HttpConnectionHandler(const std::shared_ptr<HttpRouter>& router, const std::shared_ptr<HttpProcessor::Config>& config) : HttpConnectionHandler(std::make_shared<HttpProcessor::Components>(router, config))
# HttpConnectionHandler::createShared
Create shared HttpConnectionHandler.
- @param router - oatpp::web::server::HttpRouter to route incoming requests.
- @return -
std::shared_ptr
to HttpConnectionHandler.
static std::shared_ptr<HttpConnectionHandler> createShared(const std::shared_ptr<HttpRouter>& router)
# HttpConnectionHandler::setErrorHandler
Set root error handler for all requests coming through this Connection Handler. All unhandled errors will be handled by this error handler.
- @param errorHandler - oatpp::web::server::handler::ErrorHandler.
void setErrorHandler(const std::shared_ptr<handler::ErrorHandler>& errorHandler)
# HttpConnectionHandler::addRequestInterceptor
Add request interceptor. Request interceptors are called before routing happens. If multiple interceptors set then the order of interception is the same as the order of calls to addRequestInterceptor
.
- @param interceptor - oatpp::web::server::interceptor::RequestInterceptor.
void addRequestInterceptor(const std::shared_ptr<interceptor::RequestInterceptor>& interceptor)
# HttpConnectionHandler::addResponseInterceptor
Add response interceptor. If multiple interceptors set then the order of interception is the same as the order of calls to addResponseInterceptor
.
- @param interceptor - oatpp::web::server::interceptor::RequestInterceptor.
void addResponseInterceptor(const std::shared_ptr<interceptor::ResponseInterceptor>& interceptor)
# HttpConnectionHandler::handleConnection
Implementation of oatpp::network::ConnectionHandler::handleConnection().
- @param connection - oatpp::data::stream::IOStream representing connection.
void handleConnection(const provider::ResourceHandle<IOStream>& connection,
const std::shared_ptr<const ParameterMap>& params) override
# HttpConnectionHandler::stop
Tell all worker threads to exit when done.
void stop() override
# HttpConnectionHandler::getConnectionsCount
Get connections count.
- @return
v_uint64 getConnectionsCount()