1

我使用 helidon SE 1.4.4,如何为所有响应添加拦截器。我的路线是:

return Routing.builder()
            .register(JsonSupport.create())
            .register("/api/files", health)           // Health at "/health"
            .register("/api/files", metrics)          // Metrics at "/metrics"
            .register("/api/files/storage", fileService)
            .register("/api/files", OpenAPISupport.create(config))
            .build();

我想使用拦截器在我的所有响应中添加特殊标题。

4

1 回答 1

0

Maybe one of the any methods on Routing.Builder might work for you.

https://helidon.io/docs/latest/apidocs/io/helidon/webserver/Routing.Builder.html

You would add what Helidon refers to as a Handler as opposed to what you called an interceptor, but from what you described that sounds like the behavior you want.

Hope that works.

于 2020-06-08T18:58:03.490 回答