Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeGetUserReq(logger log.Logger) func(context.Context, *http.Request) (interface{}, error)
- func DecodeLoginReq(logger log.Logger) func(context.Context, *http.Request) (interface{}, error)
- func DecodeReq(r *http.Request, i interface{}) (interface{}, error)
- func DecodeUpdatePhoneReq(logger log.Logger) func(context.Context, *http.Request) (interface{}, error)
- func DefaultEncodeResponse(logger log.Logger) func(context.Context, http.ResponseWriter, interface{}) error
- func GenerateMsgId() string
- func GetMsgId(ctx context.Context) string
- func GetUserEndpoint(service Service) endpoint.Endpoint
- func InnerMsgRequestContext(ctx context.Context, r *http.Request) context.Context
- func LoginEndpoint(service Service) endpoint.Endpoint
- func MakeHandler(logger log.Logger, userEndpoint *UserEndpoint, r *mux.Router) *mux.Router
- func NewDelayingLimitMiddelware() endpoint.Middleware
- func NewErrorLimitMiddelware() endpoint.Middleware
- func NewLogginMiddelware(logger log.Logger) endpoint.Middleware
- func NewRateLimitMiddelware(b *ratelimit.Bucket) endpoint.Middleware
- func UpdatePhone(username, phone string) error
- func UpdatePhoneEndpoint(service Service) endpoint.Endpoint
- type BaseRes
- type GetUserReq
- type GetUserRes
- type InnerMsg
- type LoginReq
- type LoginRequest
- type LoginRes
- type LoginResponseWrapper
- type Service
- type UpdatePhoneReq
- type UpdatePhoneRes
- type User
- type UserEndpoint
- type UserService
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 DecodeLoginReq ¶
func DecodeUpdatePhoneReq ¶
func DefaultEncodeResponse ¶
func GenerateMsgId ¶
func GenerateMsgId() string
func GetUserEndpoint ¶
func InnerMsgRequestContext ¶
func LoginEndpoint ¶
func MakeHandler ¶
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 UpdatePhoneEndpoint ¶
Types ¶
type GetUserReq ¶
type GetUserReq struct {
Username string `json:"username"`
}
type GetUserRes ¶
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 NewmetricsMW ¶
type UpdatePhoneReq ¶
type UpdatePhoneRes ¶
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 ¶
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) UpdatePhone ¶
func (UserService) UpdatePhone(username, phone string) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.