Micronaut 删除注释不创建端点

Micronaut Delete Annotation not creating endpoint

我有以下控制器使用@Endpoint

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import io.micronaut.http.annotation.Body
import io.micronaut.http.annotation.Delete
import io.micronaut.management.endpoint.annotation.Endpoint
import io.micronaut.management.endpoint.annotation.Read
import io.micronaut.management.endpoint.annotation.Selector
import istc.g2g.refund.dao.RefundRepository
import istc.g2g.refund.domain.Refund

import javax.inject.Inject
import javax.inject.Singleton

@Slf4j
@Endpoint(id = "refund", defaultSensitive = false)
@Singleton
@CompileStatic
class RefundController {

    @Inject
    RefundRepository refundRepository

    @Read
    Refund get(@Selector Long tin) {
        refundRepository.findByTin(tin).orElse(null)
    }

    @Delete
    void delete (@Body String foo) {
        log.debug("Deleting")
    }
}

读取和写入端点出现查找。但是删除并不像路由端点所示:

{
    "{[/refund/{tin}],method=[GET],produces=[application/json]}": {
        "method": "istc.g2g.refund.domain.Refund istc.g2g.refund.controller.RefundController.get(java.lang.Long tin)"
    },
    "{[/routes],method=[GET],produces=[application/json]}": {
        "method": "io.reactivex.Single io.micronaut.management.endpoint.routes.RoutesEndpoint.getRoutes()"
    },
    "{[/refresh],method=[POST],produces=[application/json]}": {
        "method": "[Ljava.lang.String; io.micronaut.management.endpoint.refresh.RefreshEndpoint.refresh(java.lang.Boolean force)"
    }
}

像文档中那样对端点的请求只是显示未找到:

$ curl -X DELETE http://localhost:8083/refund
{
  "_links" : {
    "self" : {
      "href" : "/refund",
      "templated" : false
    }
  },
  "message" : "Page Not Found"
}

我找不到任何证据表明 @Delete 需要任何额外的配置。

请注意,如果我将注释更改为 @Read 并使用 GET 请求,则它可以找到。

有什么想法吗?

您使用了错误的 Delete 注释。

import io.micronaut.http.annotation.Delete -> import io.micronaut.management.endpoint.annotation.Delete

编辑:此外,@Body 注释在此上下文中没有执行任何操作。