user

package
v0.0.0-...-de569a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLimitExceed = errors.New("Rate limit exceed!")
View Source
var (
	ErrorBadRequest = errors.New("invalid request parameter")
)

Functions

func DecodeLoginRequest

func DecodeLoginRequest(ctx context.Context, r interface{}) (interface{}, error)

解码请求体

func EncodeLoginResponse

func EncodeLoginResponse(_ context.Context, r interface{}) (interface{}, error)

编码响应结果

func MakeUserEndpoint

func MakeUserEndpoint(svc UserService) endpoint.Endpoint

func NewTokenBucketLimitterWithBuildIn

func NewTokenBucketLimitterWithBuildIn(bkt *rate.Limiter) endpoint.Middleware

使用x/time/rate创建限流中间件

func NewUserServer

func NewUserServer(ctx context.Context, endpoints Endpoints) pb.UserServiceServer

Types

type Endpoints

type Endpoints struct {
	UserEndpoint endpoint.Endpoint
}

终端层,提供参数转换能力

type LoginForm

type LoginForm struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type LoginResult

type LoginResult struct {
	Ret bool  `json:"ret"`
	Err error `json:"err"`
}

type ServiceMiddleware

type ServiceMiddleware func(service UserService) UserService

中间件

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) ServiceMiddleware

日志中间件

type UserService

type UserService interface {
	CheckPassword(ctx context.Context, username string, password string) (bool, error)
}

type UserServiceImpl

type UserServiceImpl struct{}

func (UserServiceImpl) CheckPassword

func (s UserServiceImpl) CheckPassword(ctx context.Context, username string, password string) (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL