2026-07-11 16:02:57 +08:00

40 lines
841 B
C++

#ifndef PARKINGSTATUSHTTPSERVER_H
#define PARKINGSTATUSHTTPSERVER_H
#include <functional>
#include <memory>
#include <string>
#include "IVrConfig.h"
namespace Poco {
namespace Net {
class HTTPServer;
}
}
class ParkingStatusHttpServer
{
public:
using StatusProvider = std::function<std::string()>;
ParkingStatusHttpServer();
~ParkingStatusHttpServer();
ParkingStatusHttpServer(const ParkingStatusHttpServer&) = delete;
ParkingStatusHttpServer& operator=(const ParkingStatusHttpServer&) = delete;
int Start(const HttpServerConfig& config, StatusProvider statusProvider);
void Stop();
bool IsRunning() const;
std::string LastError() const;
private:
std::unique_ptr<Poco::Net::HTTPServer> m_server;
bool m_running = false;
std::string m_lastError;
};
#endif // PARKINGSTATUSHTTPSERVER_H