File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -197,25 +197,6 @@ struct IRouter {
197197 virtual TFuture<void > HandleRequest (TRequest& request, TResponse& response) = 0;
198198};
199199
200- class THelloWorldRouter : public IRouter {
201- public:
202- TFuture<void > HandleRequest (TRequest& request, TResponse& response) override {
203- if (request.Uri ().Path () == " /" ) {
204- response.SetStatus (200 );
205- response.SetHeader (" Content-Type" , " text/plain" );
206- response.SetHeader (" Connection" , " close" );
207- co_await response.SendHeaders ();
208- co_await response.WriteBodyFull (" Hello, World!" );
209- } else {
210- response.SetStatus (404 );
211- response.SetHeader (" Content-Type" , " text/plain" );
212- response.SetHeader (" Connection" , " close" );
213- co_await response.SendHeaders ();
214- co_await response.WriteBodyFull (" Not Found" );
215- }
216- }
217- };
218-
219200/* *
220201 * @brief HTTP/1.1 server that accepts connections and dispatches to a router.
221202 *
Original file line number Diff line number Diff line change 77
88using namespace NNet ;
99
10+ class THelloWorldRouter : public IRouter {
11+ public:
12+ TFuture<void > HandleRequest (TRequest& request, TResponse& response) override {
13+ if (request.Uri ().Path () == " /" ) {
14+ response.SetStatus (200 );
15+ response.SetHeader (" Content-Type" , " text/plain" );
16+ response.SetHeader (" Connection" , " close" );
17+ co_await response.SendHeaders ();
18+ co_await response.WriteBodyFull (" Hello, World!" );
19+ } else {
20+ response.SetStatus (404 );
21+ response.SetHeader (" Content-Type" , " text/plain" );
22+ response.SetHeader (" Connection" , " close" );
23+ co_await response.SendHeaders ();
24+ co_await response.WriteBodyFull (" Not Found" );
25+ }
26+ }
27+ };
28+
1029int main (int argc, char ** argv) {
1130 NNet::TInitializer init;
1231 int port = 8080 ;
You can’t perform that action at this time.
0 commit comments