View Source WeChat.Plug.HubExposer (wechat v0.12.0)

用于 Hub(中控服务器) 提供查询 AccessTokenHTTP 接口

Hub Client 会定期从 Hub(中控服务器) 的接口中获取 AccessToken

使用 Phoenix 时,将下面的代码加到 router 里面:

get "/hub/expose/:store_id/:store_key", WeChat.Plug.HubExposer, clients: [ClientsA, ...]

使用 PlugCowboy 时,将下面的代码加到 router 里面:

get "/hub/expose/:store_id/:store_key",
  to: WeChat.Plug.HubExposer,
  init_opts: [clients: [ClientsA, ...]]

注意 , 在暴露接口的同时,请注意安全合规使用,建议在使用前增加安全防护,例如:

import Plug.BasicAuth
plug :basic_auth, username: "hello", password: "secret"

get "/hub/expose/:store_id/:store_key", WeChat.Plug.HubExposer, clients: [ClientsA, ...]