#pragma once #include #include #include #include #include #include class TAutoEvent; class TThread; namespace NMock { class TMockServer { public: using TGenerator = std::function; TMockServer(ui16 port, TGenerator generator); TMockServer(const THttpServerOptions& options, TGenerator generator); ~TMockServer(); size_t GetClientCount() const; void SetGenerator(TGenerator generator); private: static void* Worker(void* arg); class TCallBack; THolder Cb_; THolder Server_; THolder Thread_; THolder Ev_; }; class TPong: public TRequestReplier { public: bool DoReply(const TReplyParams& params) override { const TParsedHttpFull parsed(params.Input.FirstLine()); const HttpCodes code = parsed.Path == "/ping" ? HTTP_OK : HTTP_NOT_FOUND; THttpResponse resp(code); resp.OutTo(params.Output); return true; } }; }