endpoint

package
v1.0.2-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLoginReqType  = errors.New("RequestType has only one type: Login")
	ErrInvalidVerifyReqType = errors.New("RequestType has only one type: Verify")
	ErrInvalidLoginRequest  = errors.New("request has only one class: AuthRequest")
	ErrInvalidVerifyRequest = errors.New("request has only one class: VerifyRequest")
	ErrResponseNull         = errors.New("response is null")
)

Functions

func MakeHealthCheckEndpoint

func MakeHealthCheckEndpoint(svc service.Service) endpoint.Endpoint

MakeHealthCheckEndpoint 创建健康检查Endpoint

func MakeLoginEndpoint

func MakeLoginEndpoint(svc service.Service) endpoint.Endpoint

func MakeVerifyEndpoint

func MakeVerifyEndpoint(svc service.Service) endpoint.Endpoint

Types

type AuthEndpoints

type AuthEndpoints struct {
	LoginEndpoint       endpoint.Endpoint
	VerifyEndpoint      endpoint.Endpoint
	HealthCheckEndpoint endpoint.Endpoint
}

The service.Service method of AuthEndpoints is used for the endpoint of the client

func (AuthEndpoints) Login

func (ue AuthEndpoints) Login(ctx context.Context, username, password string, unexpired bool) (string, error)

func (AuthEndpoints) Verify

func (ue AuthEndpoints) Verify(ctx context.Context, token string) (bool, error)

type AuthRequest

type AuthRequest struct {
	RequestType string `json:"request_type"`
	Username    string `json:"username"`
	Password    string `json:"password"`
	Unexpired   bool   `json:"unexpired"`
}

type AuthResponse

type AuthResponse struct {
	Result string `json:"result"`
	Error  error  `json:"error"`
}

type HealthRequest

type HealthRequest struct{}

HealthRequest 健康检查请求结构

type HealthResponse

type HealthResponse struct {
	Status bool `json:"status"`
}

HealthResponse 健康检查响应结构

type VerifyRequest

type VerifyRequest struct {
	ResquesType string `json:"resques_type"`
	Token       string `json:"token"`
}

type VerifyResponse

type VerifyResponse struct {
	Result bool  `json:"result"`
	Error  error `json:"error"`
}

Jump to

Keyboard shortcuts

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