user

package
v0.0.0-...-201036b Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ERRORLIMIT = 10
View Source
const INNERMSG = "INNERMSG"
View Source
const METHOD = "method"
View Source
const MSGID = "MsgId"
View Source
const RATELIMIT = 100

Variables

View Source
var Users = make(map[string]User, 10)

Functions

func DecodeGetUserReq

func DecodeGetUserReq(logger log.Logger) func(context.Context, *http.Request) (interface{}, error)

func DecodeLoginReq

func DecodeLoginReq(logger log.Logger) func(context.Context, *http.Request) (interface{}, error)

func DecodeReq

func DecodeReq(r *http.Request, i interface{}) (interface{}, error)

func DecodeUpdatePhoneReq

func DecodeUpdatePhoneReq(logger log.Logger) func(context.Context, *http.Request) (interface{}, error)

func DefaultEncodeResponse

func DefaultEncodeResponse(logger log.Logger) func(context.Context, http.ResponseWriter, interface{}) error

func GenerateMsgId

func GenerateMsgId() string

func GetMsgId

func GetMsgId(ctx context.Context) string

func GetUserEndpoint

func GetUserEndpoint(service Service) endpoint.Endpoint

func InnerMsgRequestContext

func InnerMsgRequestContext(ctx context.Context, r *http.Request) context.Context

func LoginEndpoint

func LoginEndpoint(service Service) endpoint.Endpoint

func MakeHandler

func MakeHandler(logger log.Logger, userEndpoint *UserEndpoint, r *mux.Router) *mux.Router

func NewDelayingLimitMiddelware

func NewDelayingLimitMiddelware() endpoint.Middleware

func NewErrorLimitMiddelware

func NewErrorLimitMiddelware() endpoint.Middleware

func NewLogginMiddelware

func NewLogginMiddelware(logger log.Logger) endpoint.Middleware

func NewRateLimitMiddelware

func NewRateLimitMiddelware(b *ratelimit.Bucket) endpoint.Middleware

func UpdatePhone

func UpdatePhone(username, phone string) error

func UpdatePhoneEndpoint

func UpdatePhoneEndpoint(service Service) endpoint.Endpoint

Types

type BaseRes

type BaseRes struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type GetUserReq

type GetUserReq struct {
	Username string `json:"username"`
}

type GetUserRes

type GetUserRes struct {
	Body User   `json:"body"`
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type InnerMsg

type InnerMsg struct {
	MsgId string
}

type LoginReq

type LoginReq struct {
	Username string `json:"username"`
	Pwd      string `json:"pwd"`
}

type LoginRequest

type LoginRequest struct {
	// in: body
	Body LoginReq
}

swagger:parameters

type LoginRes

type LoginRes struct {
	Body User   `json:"body"`
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type LoginResponseWrapper

type LoginResponseWrapper struct {
	// in: body
	Body LoginRes
}

LoginRes

swagger:response LoginResponseWrapper

type Service

type Service interface {
	Login(username, pwd string) (User, error)
	UpdatePhone(username, phone string) error
	GetUser(username string) (User, error)
}

func NewLogService

func NewLogService(logger log.Logger, s Service) Service

func NewmetricsMW

func NewmetricsMW(s Service) Service

type UpdatePhoneReq

type UpdatePhoneReq struct {
	Username string `json:"username"`
	Phone    string `json:"phone"`
}

type UpdatePhoneRes

type UpdatePhoneRes struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type User

type User struct {
	Id       string `json:"id"`
	Username string `json:"username"`
	Pwd      string `json:"pwd"`
	Age      int    `json:"age"`
	Sid      string `json:"sid"`
	Balance  string `json:"balance"`
	Phone    string `json:"phone"`
}

func CheckLogin

func CheckLogin(username, pwd string) (User, error)

func GetUser

func GetUser(username string) (User, error)

func (User) String

func (u User) String() string

type UserEndpoint

type UserEndpoint struct {
	Login       endpoint.Endpoint
	UpdatePhone endpoint.Endpoint
	GetUser     endpoint.Endpoint
}

func MakeEndPoint

func MakeEndPoint(logger log.Logger, service Service) *UserEndpoint

type UserService

type UserService struct {
}

func (UserService) GetUser

func (UserService) GetUser(username string) (User, error)

func (UserService) Login

func (UserService) Login(username, pwd string) (User, error)

func (UserService) UpdatePhone

func (UserService) UpdatePhone(username, phone string) error

Directories

Path Synopsis
Package user User API.
Package user User API.

Jump to

Keyboard shortcuts

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