0
  1. This code is an attempt to replace a service that already works in production, written in java, with one written in rust.
  2. This service will serve as a sidecar proxy for a redis cluster, exposing an api rest. It needs to maintain compatibility with the current api.

The Route is:

"/api/keys/{path:*}" 

In path we can put de name of the key for redis, and can contain any format below:

/api/keys/users/41728391
/api/keys/users/1000/followers
/api/keys/users/{1234}/data

this is my attempt

 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

I tried like this too:

#[get("/set/{path:*}")]...

But in two cases i get this error:

  .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>*)$
               ^

I have read the https://actix.rs/actix-web/actix_web/web/fn.resource.html

My code is : https://github.com/rogeriob2br/enge-sidecar-redis

  • 1
    Whatever you're using has exposed a leaky abstraction to you. But the error message is telling you what's wrong. Your `*` isn't applied to any regex subexpression. This is a regex, not a glob. Try `.*` instead. – BurntSushi5 Apr 10 '21 at 21:46
  • 1
    `*` is not a valid regex. You probably meant `.*`. – mcarton Apr 10 '21 at 21:46
  • To tell the truth, after I read it here, I went to check the regex again in the java service that works, and I saw that I had forgotten that dot kkk – Rogério Ferreira Apr 11 '21 at 00:30
  • Agreed. A wildcard * is not equal to regex *. – dialox Oct 27 '21 at 02:39
  • @mcarton: Please create an answer out of your comment so this can be closed and doesn't show up as unanswered by a search anymore. – Konrad Höffner Aug 11 '22 at 07:01

0 Answers0