无法在 lagom 中使用 'call' 方法
unable to use 'call' method in lagom
我正在试验 Lagom 以检查如何调用 call
、pathCall
和 namedCall
。我正在关注 lagom 的教程。我创建了一项新服务并使用以下 url 打开了 url,但出现错误
URL 已使用(我希望看到 hello2 响应)
http://localhost:9000/
错误
GET\Q/stream\EService: hello-stream (http://0.0.0.0:58322)
2GET\Q/api/hello/\E([^/]+)Service: hello (http://0.0.0.0:57797)
3POST\Q/api/hello/\E([^/]+)Service: hello (http://0.0.0.0:57797)
**4POST\Q/hello2\EService: hello (http://0.0.0.0:57797)**
我已完成以下步骤
下载模板后(参见 https://www.lagomframework.com/documentation/1.3.x/scala/IntroGetStarted.html),我更改了代码以添加新的服务调用(称为 hello2)。以下是我在 HelloService.scala
中添加的代码
named("hello")
.withCalls(
pathCall("/api/hello/:id", hello _),
pathCall("/api/hello/:id", useGreeting _),
call(hello2) //added this line in default template.
)
我将 hello2 定义为(在 HelloService.scala)
def hello2: ServiceCall[String, String]
HelloServiceImpl.scala中的代码是
override def hello2 = ServiceCall {
Future.successful("Hello2")
}
Questin 1 - 有什么错误(我想我没有从浏览器正确调用服务)?
当您说 "I guess I am not invoking the service correctly from the browser" 时,您的意思是您只是在浏览器中导航到 URL 吗?如果是这样,这将不起作用,因为 hello2 被定义为 POST 端点并且您的浏览器将发送 GET 请求。
hello2 被定义为 POST 端点,因为在您的 ServiceCall 定义中它接受请求消息。 (有关详细信息,请参阅 https://www.lagomframework.com/documentation/1.3.x/java/ServiceDescriptors.html。)
如果您将请求消息类型从 String
更改为 NotUsed
,那么 Lagom 应该开始生成一个 GET 端点。
我正在试验 Lagom 以检查如何调用 call
、pathCall
和 namedCall
。我正在关注 lagom 的教程。我创建了一项新服务并使用以下 url 打开了 url,但出现错误
URL 已使用(我希望看到 hello2 响应)
http://localhost:9000/
错误
GET\Q/stream\EService: hello-stream (http://0.0.0.0:58322)
2GET\Q/api/hello/\E([^/]+)Service: hello (http://0.0.0.0:57797)
3POST\Q/api/hello/\E([^/]+)Service: hello (http://0.0.0.0:57797)
**4POST\Q/hello2\EService: hello (http://0.0.0.0:57797)**
我已完成以下步骤
下载模板后(参见 https://www.lagomframework.com/documentation/1.3.x/scala/IntroGetStarted.html),我更改了代码以添加新的服务调用(称为 hello2)。以下是我在 HelloService.scala
中添加的代码named("hello")
.withCalls(
pathCall("/api/hello/:id", hello _),
pathCall("/api/hello/:id", useGreeting _),
call(hello2) //added this line in default template.
)
我将 hello2 定义为(在 HelloService.scala)
def hello2: ServiceCall[String, String]
HelloServiceImpl.scala中的代码是
override def hello2 = ServiceCall {
Future.successful("Hello2")
}
Questin 1 - 有什么错误(我想我没有从浏览器正确调用服务)?
当您说 "I guess I am not invoking the service correctly from the browser" 时,您的意思是您只是在浏览器中导航到 URL 吗?如果是这样,这将不起作用,因为 hello2 被定义为 POST 端点并且您的浏览器将发送 GET 请求。
hello2 被定义为 POST 端点,因为在您的 ServiceCall 定义中它接受请求消息。 (有关详细信息,请参阅 https://www.lagomframework.com/documentation/1.3.x/java/ServiceDescriptors.html。)
如果您将请求消息类型从 String
更改为 NotUsed
,那么 Lagom 应该开始生成一个 GET 端点。