概述

    Dapr 允许通过链接一系列中间件组件来定义自定义处理管道。 Dapr配置文件中定义了中件管道。 As with other building block components, middleware components are extensible and can be found in the .

    Dapr中的中间件使用文件描述,其schema如下:

    Next, a Dapr configuration defines the pipeline of middleware components for your application.

    Dapr 使用 来实现其的 HTTP 服务器。 因此,您的 HTTP 中间件也需要编写为 FastHTTP handler。 您的中间件需要实现 Middleware 接口,该接口定义 GetHandler 方法,该方法返回 fasthttp.RequestHandler:

    您的中间件组件可以贡献到 components-contrib 仓库

    在接受了 components-contrib 变更后,针对 提交另一个 pull 请求,以注册新的中间件类型。 您需要修改runtime.WithHTTPMiddleware方法中的**方法,将您的中间件注册到Dapr的运行时。