feat:完善项目
This commit is contained in:
24
rpc/client/auth.go
Normal file
24
rpc/client/auth.go
Normal file
@ -0,0 +1,24 @@
|
||||
package client
|
||||
|
||||
import "context"
|
||||
|
||||
type Auth struct {
|
||||
isTLS bool
|
||||
Value string
|
||||
}
|
||||
|
||||
const headerAuthorize string = "authorization"
|
||||
|
||||
func (a *Auth) SetIsTLS(status bool) {
|
||||
a.isTLS = status
|
||||
}
|
||||
|
||||
// GetRequestMetadata 获取当前请求认证所需的元数据
|
||||
func (a *Auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
|
||||
return map[string]string{headerAuthorize: a.Value}, nil
|
||||
}
|
||||
|
||||
// RequireTransportSecurity 是否需要基于 TLS 认证进行安全传输
|
||||
func (a *Auth) RequireTransportSecurity() bool {
|
||||
return a.isTLS
|
||||
}
|
Reference in New Issue
Block a user