Akka Typed with Akka HTTP Routes

Hello there,

I am trying to find some examples of using Akka Typed with Akka HTTP (server routing directives). I can see examples like https://developer.lightbend.com/guides/akka-http-quickstart-scala/http-server.html#the-complete-route clarifying on using untyped actors with Akka HTTP using the complete directive + ask pattern (https://doc.akka.io/docs/akka-http/current/routing-dsl/directives/future-directives/index.html).

Trying to find a similar example that would allow me to connect a typed.ActorRef to interact with HTTP request and provide a response (like https://doc.akka.io/docs/akka/current/typed/interaction-patterns.html#request-response).

Please advice,

I was able to write a HTTP complete using Akka Typed (ref: https://doc.akka.io/docs/akka/current/typed/interaction-patterns.html#request-response-with-ask-from-outside-an-actor)

      path( "entry" / Segment) { id =>
          get {
            val result: Future[TokenAuthResponse] = tokenService.ask(ref => TokenLookupService.GetTokenAttributes(id, ref))
          } ~ delete {
            val result: Future[TokenAuthResponse] = tokenService.ask(ref => TokenLookupService.DeleteToken(id, ref))

where tokenService is of type ActorRef[TokenLookupService.Command].

1 Like