File tree Expand file tree Collapse file tree 5 files changed +37
-0
lines changed Expand file tree Collapse file tree 5 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,14 @@ int main() {
108108 return resp->Json(router.Paths());
109109 });
110110
111+ router.GET("/get", [](HttpRequest* req, HttpResponse* resp) {
112+ resp->json["origin"] = req->client_addr.ip;
113+ resp->json["url"] = req->url;
114+ resp->json["args"] = req->query_params;
115+ resp->json["headers"] = req->headers;
116+ return 200;
117+ });
118+
111119 router.POST("/echo", [](HttpRequest* req, HttpResponse* resp) {
112120 resp->content_type = req->content_type;
113121 resp->body = req->body;
Original file line number Diff line number Diff line change @@ -106,6 +106,14 @@ int main() {
106106 return resp->Json(router.Paths());
107107 });
108108
109+ router.GET("/get", [](HttpRequest* req, HttpResponse* resp) {
110+ resp->json["origin"] = req->client_addr.ip;
111+ resp->json["url"] = req->url;
112+ resp->json["args"] = req->query_params;
113+ resp->json["headers"] = req->headers;
114+ return 200;
115+ });
116+
109117 router.POST("/echo", [](HttpRequest* req, HttpResponse* resp) {
110118 resp->content_type = req->content_type;
111119 resp->body = req->body;
Original file line number Diff line number Diff line change @@ -39,6 +39,14 @@ int main() {
3939 return resp->Json (router.Paths ());
4040 });
4141
42+ router.GET (" /get" , [](HttpRequest* req, HttpResponse* resp) {
43+ resp->json [" origin" ] = req->client_addr .ip ;
44+ resp->json [" url" ] = req->url ;
45+ resp->json [" args" ] = req->query_params ;
46+ resp->json [" headers" ] = req->headers ;
47+ return 200 ;
48+ });
49+
4250 router.POST (" /echo" , [](HttpRequest* req, HttpResponse* resp) {
4351 resp->content_type = req->content_type ;
4452 resp->body = req->body ;
Original file line number Diff line number Diff line change @@ -36,6 +36,15 @@ class Router {
3636 return resp->Json (router.Paths ());
3737 });
3838
39+ // curl -v http://ip:port/get?env=1
40+ router.GET (" /get" , [](HttpRequest* req, HttpResponse* resp) {
41+ resp->json [" origin" ] = req->client_addr .ip ;
42+ resp->json [" url" ] = req->url ;
43+ resp->json [" args" ] = req->query_params ;
44+ resp->json [" headers" ] = req->headers ;
45+ return 200 ;
46+ });
47+
3948 // curl -v http://ip:port/echo -d "hello,world!"
4049 router.POST (" /echo" , [](HttpRequest* req, HttpResponse* resp) {
4150 resp->content_type = req->content_type ;
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ cmd="bin/curl -v localhost:8080/data" && run_cmd
4343
4444cmd=" bin/curl -v localhost:8080/html/index.html" && run_cmd
4545
46+ cmd=" bin/curl -v localhost:8080/get?env=1" && run_cmd
47+
48+ cmd=" bin/curl -v localhost:8080/wildcard/test" && run_cmd
49+
4650cmd=" bin/curl -v localhost:8080/echo -d 'hello,world!'" && echo_cmd
4751bin/curl -v localhost:8080/echo -d ' hello,world!'
4852
You can’t perform that action at this time.
0 commit comments