POCO: How to invoke public application method

Viewed 12

I have a class that inherits from Poco::Util::ServerApplication, in the Request Factory I want to get an instance of my application (HttpFileServer) to call a public method and get data. How can this be done? c

сlass HttpFileServer : public Poco::Util::ServerApplication
{
private:
    FilesInfo m_FilesInfo;

private:
    std::unique_ptr<Poco::Net::HTTPServer> m_Serv;

private:
    void parseFilesInfo(const YAML::Node& filesNode);

    void initServer(const YAML::Node& config);
    void initialize(Application& self) override;
    int main(const std::vector<std::string>&) override;

public:
    ~HttpFileServer() override = default;

    const FilesInfo& getFilesInfo() const;
};

And RequestFactory

Poco::Net::HTTPRequestHandler* RequestFactory::createRequestHandler(const Poco::Net::HTTPServerRequest &request)
{
    HttpFileServer::Application& app = HttpFileServer::instance();

    app.getFilesInfo(); // can't invoke
    app.logger().information("Request from %s", request.clientAddress().toString());

    auto files = app.

    if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET)
    {
        return new MainPageHandler;
    }

    if (request.getURI() == "/request")
    {
        return nullptr;
    }

    return nullptr;
}
0 Answers
Related