Lightbend Lagom和Akka:无法达到拉格姆服务的休息端点

Har*_*ara 4 rest scala akka http-status-code-404 lagom

我正在创建lagom简单应用程序,定义一个休息终点并使用休息客户端邮递员命中终点.但作为回应我得到,行动没有发现错误.我将Akka与lagom集成,以下是我的代码:

服务:

trait TwitterSchedulerService extends Service {

  def doWork: ServiceCall[NotUsed, Done]

  override def descriptor: Descriptor = {
    import Service._
    named("scheduler").withCalls(
      call(doWork)
    )
  }
}
Run Code Online (Sandbox Code Playgroud)

ServiceImpl:

class TwitterSchedulerServiceImpl(system: ActorSystem) extends TwitterSchedulerService {

  override def doWork = ServiceCall { _ =>
    Future {
      println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ")
      Done
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

装载机配置:

class TwitterLoader extends LagomApplicationLoader {

  override def load(context: LagomApplicationContext): LagomApplication =
    new TwitterApplication(context) {
      override def serviceLocator = NoServiceLocator
    }

}

object TwitterSerializerRegistry extends JsonSerializerRegistry {

  override val serializers = Vector(
    JsonSerializer[String]
  )
}

abstract class TwitterApplication(context: LagomApplicationContext) extends LagomApplication(context)
  with CassandraPersistenceComponents with AhcWSComponents {

  override lazy val lagomServer = LagomServer.forServices(
    bindService[TwitterSchedulerService].to(wire[TwitterSchedulerServiceImpl])
  )
  override lazy val jsonSerializerRegistry = TwitterSerializerRegistry
}
Run Code Online (Sandbox Code Playgroud)

我正在关注lagom文档http://www.lagomframework.com/documentation/1.3.x/scala/Akka.html.我想知道,为什么会出现这个错误,事件所有的休息点都被定义了???

Tim*_*ore 9

您的服务在http:// localhost:57211上运行

http:// localhost:9000正在运行Service Gateway服务器,该服务器充当项目中运行的所有服务的反向代理.

可以将服务网关配置为将服务调用转发到您的服务,但默认情况下不会.您可以通过在服务描述符中定义ACL(访问控制列表)来配置它.

最常见的是,您将呼叫withAutoAcl(true)自动将所有服务呼叫路径转发到您的服务:

trait TwitterSchedulerService extends Service {

  def doWork: ServiceCall[NotUsed, Done]

  override def descriptor: Descriptor = {
    import Service._
    named("scheduler").withCalls(
      call(doWork)
    ).withAutoAcl(true)
  }
}
Run Code Online (Sandbox Code Playgroud)

如果您希望更多地控制从Service Gateway转发到后端服务的路径,您可以调用withAcls以传递应从Service Gateway转发的显式方法和路径正则表达式的列表:

trait TwitterSchedulerService extends Service {

  def doWork: ServiceCall[NotUsed, Done]

  override def descriptor: Descriptor = {
    import Service._
    named("scheduler").withCalls(
      call(doWork)
    ).withAcls(
      ServiceAcl.forPathRegex("/doWork")
    )
  }
}
Run Code Online (Sandbox Code Playgroud)

如果部署到ConductR(Lightbend Production Suite的一部分),则服务描述符中的这些ACL配置也用于生成ConductR ACL配置.