我有以下工作示例
val headers = HttpHeaders()
headers.add("Content-Type", "application/merge-patch+json")
mockMvc.perform(
patch(path)
.headers(headers)
.content(objectMapper.writeValueAsString(patchRequest)),
).andExpect(status().isOk)
.andReturn()
我想用KotlinDSL重写它
val result = mockMvc.patch(path) {
//this.header = headers
content = objectMapper.writeValueAsString(patchRequest)
}.andExpect{ status { isOk() } }
.andReturn()
我不知道如何传递自定义头。有办法吗?
1条答案
按热度按时间tvokkenx1#
特别是从问题的情况下,这种方法将工作: