mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-02 12:07:35 +08:00
refactor: mv the var mqtt_client_id to plugin level (#6241)
This commit is contained in:
parent
03324ee6f9
commit
e9e53e8152
@ -148,7 +148,6 @@ do
|
||||
balancer_ip = true,
|
||||
balancer_port = true,
|
||||
consumer_name = true,
|
||||
mqtt_client_id = true,
|
||||
route_id = true,
|
||||
route_name = true,
|
||||
service_id = true,
|
||||
@ -254,10 +253,6 @@ function _M.register_var(name, getter)
|
||||
error("the getter of registered var should be a function")
|
||||
end
|
||||
|
||||
if apisix_var_names[name] then
|
||||
error(name .. " is registered")
|
||||
end
|
||||
|
||||
apisix_var_names[name] = getter
|
||||
end
|
||||
|
||||
|
@ -23,6 +23,11 @@ local str_byte = string.byte
|
||||
local str_sub = string.sub
|
||||
|
||||
|
||||
core.ctx.register_var("mqtt_client_id", function(ctx)
|
||||
return ctx.mqtt_client_id
|
||||
end)
|
||||
|
||||
|
||||
local schema = {
|
||||
type = "object",
|
||||
properties = {
|
||||
|
@ -26,18 +26,18 @@ additional variables.
|
||||
|
||||
List in alphabetical order:
|
||||
|
||||
| Variable Name | Description | Example |
|
||||
|------------------|-------------------------| --------- |
|
||||
| balancer_ip | the IP of picked upstream server | 1.1.1.1 |
|
||||
| balancer_port | the port of picked upstream server | 80 |
|
||||
| consumer_name | username of `consumer` | |
|
||||
| graphql_name | the [operation name](https://graphql.org/learn/queries/#operation-name) of GraphQL | HeroComparison |
|
||||
| graphql_operation | the operation type of GraphQL | mutation |
|
||||
| graphql_root_fields | the top level fields of GraphQL | ["hero"] |
|
||||
| mqtt_client_id | the client id in MQTT protocol | |
|
||||
| route_id | id of `route` | |
|
||||
| route_name | name of `route` | |
|
||||
| service_id | id of `service` | |
|
||||
| service_name | name of `service` | |
|
||||
| Variable Name | Origin | Description | Example |
|
||||
|------------------|---------|--------------------| --------- |
|
||||
| balancer_ip | core | the IP of picked upstream server | 1.1.1.1 |
|
||||
| balancer_port | core | the port of picked upstream server | 80 |
|
||||
| consumer_name | core | username of `consumer` | |
|
||||
| graphql_name | core | the [operation name](https://graphql.org/learn/queries/#operation-name) of GraphQL | HeroComparison |
|
||||
| graphql_operation | core | the operation type of GraphQL | mutation |
|
||||
| graphql_root_fields | core | the top level fields of GraphQL | ["hero"] |
|
||||
| mqtt_client_id | mqtt-proxy | the client id in MQTT protocol | |
|
||||
| route_id | core | id of `route` | |
|
||||
| route_name | core | name of `route` | |
|
||||
| service_id | core | id of `service` | |
|
||||
| service_name | core | name of `service` | |
|
||||
|
||||
You can also [register your own variable](./plugin-develop.md#register-custom-variable).
|
||||
|
Loading…
Reference in New Issue
Block a user