| commit | 5c16eca721e1b3f6211d0aa0fb894f3554bae7f7 | [log] [tgz] |
|---|---|---|
| author | liuhy <liuhongyu@apache.org> | Thu Jan 02 10:18:35 2025 +0800 |
| committer | liuhy <liuhongyu@apache.org> | Thu Jan 02 10:18:35 2025 +0800 |
| tree | d3b3d15a2580571fff69fe98f7bfccf54c788ad6 | |
| parent | c71ec3cd7d51f72000dafd4ed1420fde0a0e82d6 [diff] | |
| parent | e1a5462480c1590f85a7ff60681dc0c00f08955c [diff] |
Merge branch 'refs/heads/main' into release/release_note
Apache-Shenyu-Client for python client allows you to access ShenYu Gateway, it supports registry python service to ShenYu Gateway.
pip3 install Apache-ShenYu-Client -i https://pypi.python.org/simple
import package: from apache_shenyu_client.config import GatewayConfig from apache_shenyu_client.register import register_uri, register_metadata, register_all_metadata
First, modify the configuration according to the project situation, If you do not configure it, you will not be able to use apache_shenyu_client.
GatewayConfig.test = {
"servers": "xx.xx.xx.xx",
"port": 1001
}
GatewayConfig.uri = {
"app_name": "app2", # app name
"host": "172.24.43.28", # python service host
"port": 8000, # python service port
"context_path": "/flask_test", # context_path
"environment": "test", # environment
"rpc_type": "http" # rpc type
}
GatewayConfig.register = {
"register_type": "http",
"servers": "xx.xx.xx.xx",
"props": {
"username": "admin",
"password": "123456"
}
}
Proxy all api
@register_uri@register_all_metadata(register_all=True)Proxy some api
@user.route('/search', methods=['GET'])
def user_search_handler():
data = UserBusiness.search_by_nickname()
return json_detail_render(0, data)`
proxy:
@register_metadata("/search")
@user.route('/search', methods=['GET'])
def user_search_handler():
data = UserBusiness.search_by_nickname()
return json_detail_render(0, data)
import package from apache_shenyu_client.config import GatewayConfig from apache_shenyu_client.api import GatewayProxy gt = GatewayProxy()
GatewayConfig.uri = {
"app_name": "app2", # app name
"host": "172.24.43.28", # python service host
"port": 8000, # python service port
"context_path": "/flask_test", # context_path
"environment": "test", # environment
"rpc_type": "http" # rpc type
}
Register uri
gt.register_uri() and "/helloqq2" is the path to register
gt.register_metadata("/helloqq2")
gt.register_metadata(register_all=True)