gpt4 book ai didi

corda - 如何在 corda api 中使用 post 而不是 put?

转载 作者:行者123 更新时间:2023-12-02 00:59:47 25 4
gpt4 key购买 nike

**你如何在corda api中使用post?我们可以使用 post 代替 put 方法吗?

像@PUT 一样,@POST 是否有任何选项**

 @PUT
@Path("create-iou")
fun createIOU(@QueryParam("iouValue") iouValue: Int,
@QueryParam("partyName") partyName: CordaX500Name?):
Response {
if (iouValue <= 0 ) {
return Response.status(BAD_REQUEST).entity("Query parameter 'iouValue' must be non-negative.\n").build()
}
if (partyName == null) {
return Response.status(BAD_REQUEST).entity("Query parameter 'partyName' missing or has wrong format.\n").build()
}
val otherParty = rpcOps.wellKnownPartyFromX500Name(partyName) ?:
return Response.status(BAD_REQUEST).entity("Party named $partyName cannot be found.\n").build()

return try {
val signedTx = rpcOps.startTrackedFlow(::Initiator, iouValue, otherParty).returnValue.getOrThrow()
Response.status(CREATED).entity("Transaction id ${signedTx.id} committed to ledger.\n").build()

} catch (ex: Throwable) {
logger.error(ex.message, ex)
Response.status(BAD_REQUEST).entity(ex.message!!).build()
}
}

最佳答案

是的,只需将注释更改为@POST:

@PUT
@Path("create-iou")
fun createIOU(@QueryParam("iouValue") iouValue: Int,
@QueryParam("partyName") partyName: CordaX500Name?): Response {

...

}

关于corda - 如何在 corda api 中使用 post 而不是 put?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51471439/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com