loongs-zhang commented on code in PR #1037: URL: https://github.com/apache/shenyu-website/pull/1037#discussion_r1795101276
########## shenyuClientRust/http.md: ########## @@ -0,0 +1,158 @@ +--- +description: http +title: Http Example +--- +# The Http type Register + +**1.Fist make sure The ShenYuAdmin is Started, and ShenYuAdmin service active port is 9095.** + +```log +//Or you will see this error : + +2024-10-09T07:23:26.970200Z ERROR shenyu_client_rust::core: Can't get register token +2024-10-09T07:23:29.015550Z ERROR shenyu_client_rust::core: [ERROR], register metadata to http://127.0.0.1:9095/shenyu-client/register-metadata failed, app_name: shenyu_client_app, path: /health, contextPath: /xxx +2024-10-09T07:23:31.039558Z ERROR shenyu_client_rust::core: [ERROR], register metadata to http://127.0.0.1:9095/shenyu-client/register-metadata failed, app_name: shenyu_client_app, path: /users, contextPath: /xxx +2024-10-09T07:23:33.089412Z ERROR shenyu_client_rust::core: [ERROR], register uri to http://127.0.0.1:9095/shenyu-client/register-uri failed, app_name: shenyu_client_app, host: 10.10.9.198, port: 3000 +2024-10-09T07:23:35.124249Z ERROR shenyu_client_rust::core: [ERROR], register discover config to http://127.0.0.1:9095/shenyu-client/register-discoveryConfig failed, discovery_type: zookeeper, host: 10.10.9.198, port: 3000 + +``` + +**2.Step 1 Get shenyu_admin_client. (Register service need this)** + +```yml +# a yml-format config file +shenyu: + register: + register_type: "http" + servers: "http://127.0.0.1:9095" + props: + username: "admin" + password: "123456" +``` + +```markdown +//init config. +let config = ShenYuConfig::from_yaml_file("config.yml").unwrap(); +// init shenyu client. +let client = ShenyuClient::new(config, app.app_name(), app.uri_infos(), 3000).unwrap(); +``` + +```log +The adminToken like this : +{ + "code":200, + "message":"login dashboard user success", + "data":{ + "id":"1", + "userName":"admin", + "role":1, + "enabled":true, + "dateCreated":"2018-06-23 15:12:22", + "dateUpdated":"2024-10-03 02:29:39", + "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjUwNjc5OTQ2fQ.K92Il2kmJ0X3FgjY4igW35-pw9nsf5VKdUyqBoyIaF4" + } +} + +When you success get toekn, you will see this : +this is ShenYu Admin client token -> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjUwNjc5OTQ2fQ.K92Il2kmJ0X3FgjY4igW35-pw9nsf5VKdUyqBoyIaF4 +``` + +**3.Step 2 Register MetaData to ShenYu GateWay.** Review Comment: Step 2 Register to ShenYu admin. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@shenyu.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org