[Feature: add default handle logic & refactor shenyu_admin_client] (#5)

* [feature: add default handle logic & refactor shenyu_admin_client.go.]

* [feature: fix default password.]

Co-authored-by: lishuo <lishuo@mesomia-tech.com>
6 files changed
tree: 9f5b1d8b98aa56d31d01501e645e048ba12142ec
  1. clients/
  2. common/
  3. example/
  4. model/
  5. .asf.yaml
  6. .gitignore
  7. DISCLAIMER
  8. LICENSE
  9. NOTICE
  10. README.md
README.md

shenyu-client-golang 中文

license


Shenyu-client-golang

Shenyu-client-golang for Go client allows you to access ShenYu Gateway,it supports registory go service to ShenYu Gateway.

Requirements

Supported Go version over 1.12

Supported ShenYu version over 2.4.3

Installation

Use go get to install SDK:

$ go get -u github.com/apache/incubator-shenyu-client-golang

How to use

1.Fist make sure The ShenYuAdmin is Started, and ShenYuAdmin service active port is 9095.

2.Get shenyu_admin_client. (Register service need this)

//init ShenYuAdminClient
adminClient := &model.ShenYuAdminClient{
    UserName: "admin",  //require user provide
    Password: "123456", //require user provide
}

adminTokenData, err := clients.NewShenYuAdminClient(adminClient)

The adminTokenData 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":"2022-03-09 15:08:14",
        "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjUwNjc5OTQ2fQ.K92Il2kmJ0X3FgjY4igW35-pw9nsf5VKdUyqBoyIaF4"
    }
}

When you success get toekn, you will see this :
this is ShenYu Admin client token -> eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjUwNjc5OTQ2fQ.K92Il2kmJ0X3FgjY4igW35-pw9nsf5VKdUyqBoyIaF4