cinatra icon indicating copy to clipboard operation
cinatra copied to clipboard

url中正则表达式的匹配

Open zhaojiecll opened this issue 4 years ago • 2 comments

你好,我正在使用你们的cinatra做个大文件上传下载的C++服务器,根据我们的业务使用,现在遇到一个问题,我们的url类似这样的http://127.0.0.1:8080\upload\video\XXXX\20190906,upload后面的字符串我们是作为存储路径,每次都会变化,我使用你们的库,尝试使用正则表达式进行path的通配,发现无法正常通配,正则表达式应该是正确的。 server.set_http_handler<POST>("/upload/[^\s]*", [](request& req, response& res) { if (req.get_content_type() == content_type::multipart) { auto& files = req.get_upload_files(); for (auto& file : files) { std::cout << file.get_file_path() << " " << file.get_file_size() << std::endl; } res.render_string("multipart finished"); } else { res.render_string(" not multipart data"); } });

我使用的另外一个第三方库是可以的,想要咨询下,是否支持path的正则表达式通配,如果支持,是有demo可以借鉴,谢谢

zhaojiecll avatar Sep 06 '19 03:09 zhaojiecll

目前不支持正则表达式,需要自行进行参数处理

------------------ 原始邮件 ------------------ 发件人: "zhaojiecll"[email protected]; 发送时间: 2019年9月6日(星期五) 中午11:17 收件人: "qicosmos/cinatra"[email protected]; 抄送: "Subscribed"[email protected]; 主题: [qicosmos/cinatra] url中正则表达式的匹配 (#121)

你好,我正在使用你们的cinatra做个大文件上传下载的C++服务器,根据我们的业务使用,现在遇到一个问题,我们的url类似这样的http://127.0.0.1:8080\upload\video\XXXX\20190906,upload后面的字符串我们是作为存储路径,每次都会变化,我使用你们的库,尝试使用正则表达式进行path的通配,发现无法正常通配,正则表达式应该是正确的。 server.set_http_handler("/upload/[^\s]*", [](request& req, response& res) { if (req.get_content_type() == content_type::multipart) { auto& files = req.get_upload_files(); for (auto& file : files) { std::cout << file.get_file_path() << " " << file.get_file_size() << std::endl; } res.render_string("multipart finished"); } else { res.render_string(" not multipart data"); } });

我使用的另外一个第三方库是可以的,想要咨询下,是否支持path的正则表达式通配,如果支持,是有demo可以借鉴,谢谢

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

xmh0511 avatar Sep 06 '19 03:09 xmh0511

了解了,非常感谢您的回答!

| | zhaojiecll | | 邮箱:[email protected] |

Signature is customized by Netease Mail Master

在2019年09月06日 11:25,xmh0511 写道: 目前不支持正则表达式,需要自行进行参数处理

------------------ 原始邮件 ------------------ 发件人: "zhaojiecll"[email protected]; 发送时间: 2019年9月6日(星期五) 中午11:17 收件人: "qicosmos/cinatra"[email protected]; 抄送: "Subscribed"[email protected]; 主题: [qicosmos/cinatra] url中正则表达式的匹配 (#121)

你好,我正在使用你们的cinatra做个大文件上传下载的C++服务器,根据我们的业务使用,现在遇到一个问题,我们的url类似这样的http://127.0.0.1:8080\upload\video\XXXX\20190906,upload后面的字符串我们是作为存储路径,每次都会变化,我使用你们的库,尝试使用正则表达式进行path的通配,发现无法正常通配,正则表达式应该是正确的。 server.set_http_handler("/upload/[^\s]*", [](request& req, response& res) { if (req.get_content_type() == content_type::multipart) { auto& files = req.get_upload_files(); for (auto& file : files) { std::cout << file.get_file_path() << " " << file.get_file_size() << std::endl; } res.render_string("multipart finished"); } else { res.render_string(" not multipart data"); } });

我使用的另外一个第三方库是可以的,想要咨询下,是否支持path的正则表达式通配,如果支持,是有demo可以借鉴,谢谢

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

zhaojiecll avatar Sep 06 '19 03:09 zhaojiecll

最新代码已经支持了正则

qicosmos avatar Jan 14 '24 12:01 qicosmos

good job

---- 回复的原邮件 ---- | 发件人 | @.> | | 发送日期 | 2024年01月14日 20:38 | | 收件人 | qicosmos/cinatra @.> | | 抄送人 | zhaojiecll @.>, Author @.> | | 主题 | Re: [qicosmos/cinatra] url中正则表达式的匹配 (#121) |

Closed #121 as completed.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

zhaojiecll avatar Jan 14 '24 12:01 zhaojiecll