endpoints.go 592 B

1234567891011121314151617181920212223242526272829
  1. package user
  2. import (
  3. "context"
  4. "github.com/go-kit/kit/endpoint"
  5. )
  6. type LoginForm struct {
  7. Username string `json:"username"`
  8. Password string `json:"password"`
  9. }
  10. type LoginResult struct {
  11. Ret bool `json:"ret"`
  12. Err error `json:"err"`
  13. }
  14. type Endpoints struct {
  15. UserEndpoint endpoint.Endpoint
  16. }
  17. func MakeUserEndpoint(svc UserService) endpoint.Endpoint {
  18. return func(ctx context.Context, form interface{}) (result interface{}, err error) {
  19. req := form.(LoginForm)
  20. ret, err := svc.CheckPassword(ctx, req.Username, req.Password)
  21. return LoginResult{Ret: ret, Err: err}, nil
  22. }
  23. }