PatternsCS.ask is Deprecated I need the alternative when using Akka HTTP

In the quickstart guide for Akka Http: there is this snippet of code being used:

       CompletionStage<ActionPerformed> userCreated = PatternsCS
                            .ask(userRegistryActor, new CreateUser(user), timeout)
                            .thenApply(obj ->(ActionPerformed) obj);

However PatternsCS is deprecated. I’m currently unable to find an alternative when using Akka Http. I’ve found many solutions using Akka but I can’t seem to get my head around how to transfer this into Akka Http.
Any help will be greatly appreciated.

It looks like this example was updated after you posted this, but it could still be improved further.

The simplest fix would be to change timeout to a java.time.Duration instance and then use Patterns.ask instead of PatternsCS.

Thanks for getting back to me Tim. I’ve now fixed it as per the new quickstart guide.