首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何处理Finatra中的put请求?

如何处理Finatra中的put请求?
EN

Stack Overflow用户
提问于 2017-10-13 12:11:07
回答 2查看 227关注 0票数 5

我有一个有put端点的服务。我想要能够访问网址和身体。我怎样才能做到这一点。

这是我的端点:

代码语言:javascript
复制
put("/:customerNum") { foo: Foo =>
    val custNum = ???
  }

如何访问customerNum?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-10-13 13:25:50

在这里,如何提取与请求相关的内容

代码语言:javascript
复制
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
    }
票数 4
EN

Stack Overflow用户

发布于 2017-10-13 13:07:35

代码语言:javascript
复制
put( / string) { (customerNumber: String) =>
    s"$customerNumber!"
  }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46729645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档