regex - 资源正则表达式导致恐慌
问题描述
- 这段代码试图用 rust 编写的替换已经在生产环境中工作的服务,用 java 编写。
- 这个服务将作为一个 redis 集群的 sidecar 代理,暴露一个 api rest。它需要保持与当前 api 的兼容性。
路线是:
"/api/keys/{path:*}"
在 path 中,我们可以输入 redis 的键名,并且可以包含以下任何格式:
/api/keys/users/41728391
/api/keys/users/1000/followers
/api/keys/users/{1234}/data
这是我的尝试
HttpServer::new(move || App::new()
.data(redis_config)
.service(
web::resource("/set/{path:*}").route(web::put().to(set_key))
) ).bind(("127.0.0.1", 8080))?
.run()
.await
我也试过这样:
#[get("/set/{path:*}")]...
但在两种情况下,我会收到此错误:
.service(web::resource("/set/{path:*}").route(web::put().to(path_regex)))
| ^^^^^^^^^^ the trait `Factory<_, _, _>` is not implemented for `path_regex`
thread 'thread 'actix-rt:worker:1actix-rt:worker:0' panicked at '' panicked at 'Wrong path pattern: "/set/{path:*}" regex parse error:
^/set/(?P<path>*)$
^
error: repetition operator missing expressionWrong path pattern: "/set/{path:*}" regex parse error:
^/set/(?P<path>*)$
^
我已阅读https://actix.rs/actix-web/actix_web/web/fn.resource.html
解决方案
推荐阅读
- wiremock - 我可以将 Spring Cloud Contract 定义为代理,并且只为端点子集制作存根吗?
- c++ - '--p' 如何在 for(p=&(*L).elem[(*L).length-1];p>=q;--p) 中工作?
- c++ - 我应该在 ECS 中使用静态类吗?
- python - 计算每个 bin 中的值数:Python
- java - 如何在 Java 中删除新行
- mysql - 如何在laravel的where子句中使用alised列
- sql - Oracle 选择索引优化
- apache-spark - 本地模式下的 Apache Spark 结构化流字数统计示例超慢
- javascript - yii2 Fullcalendar - 为什么警告 CalEvent 工作但不更新 innerHtml?
- git - Git守护程序克隆边带解复用器中的致命错误并读取错误无效参数