首页 > 解决方案 > Wso2 apim 自定义指标

问题描述

我们计划部署 apim 并按自定义指标(请求正文的属性之一中的字符数)向开发人员收费。是否可以在不修改 apim 源的情况下做到这一点?

标签: wso2wso2-am

解决方案


您可以使用以下方法执行此操作。

  1. 添加全局或 API 级别的自定义中介策略 - https://apim.docs.wso2.com/en/latest/learn/api-gateway/message-mediation/sharing-the-default-mediation-flow-of-api-请求/#creating-per-api-mediation-policies

您可以编写一个类中介来读取请求正文并进行任何计算。然后以异步方式将数据发布到另一个服务。

  1. 您可以编写一个处理程序来做同样的事情 - https://apim.docs.wso2.com/en/latest/develop/extending-api-manager/extending-gateway/writing-custom-handlers/#introducing-handlers

推荐阅读