dee*_*eep 5 scala finagle twitter-finagle finatra
我有一个具有put端点的服务.我希望能够访问url param以及body.我如何实现这一目标.
这是我的终点:
put("/:customerNum") { foo: Foo =>
val custNum = ???
}
Run Code Online (Sandbox Code Playgroud)
我如何访问customerNum?
这里如何提取与请求相关的内容:
put("/:customerNum") { request =>
// Get request body
val body = request.getContentString
// Get content type
val contentType = request.contentType
// Get customer number
val customerNum = request.routeParams.get("customerNum")
println(s"Customer number: ${customerNum}. Content Type: $contentType. Body: $body")
render.plain("ok").toFuture
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
155 次 |
| 最近记录: |