You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

61 lines
1.8 KiB

package user
import (
"context"
"git.diulo.com/mogfee/kit/transport/http"
"git.diulo.com/mogfee/kit/middleware/jwt"
)
type UserHTTPServer interface {
List(context.Context, *LoginRequest) (*LoginResponse, error)
Login(context.Context, *LoginRequest) (*LoginResponse, error)
Delete(context.Context, *LoginRequest) (*LoginResponse, error)
}
func RegisterUserHTTPServer(s *http.Server, srv UserServer) {
r := s.Route("/")
r.GET("/api/v1/user/list", _User_List0_HTTP_Handler(srv))
r.GET("/api/v1/user/login", _User_Login0_HTTP_Handler(srv))
}
func _User_List0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in LoginRequest
//user:list
var newCtx context.Context = ctx
newCtx = jwt.SetAuthKeyContext(ctx, "user:list")
if err := ctx.BindQuery(&in); err != nil {
return err
}
http.SetOperation(ctx, "/com.diulo.api.user/list")
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.List(ctx, req.(*LoginRequest))
})
out, err := h(newCtx, &in)
if err != nil {
return err
}
reply := out.(*LoginResponse)
return ctx.Result(200, reply)
}
}
func _User_Login0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in LoginRequest
// none
var newCtx context.Context = ctx
newCtx = jwt.SetAuthKeyContext(ctx, "none")
if err := ctx.BindQuery(&in); err != nil {
return err
}
http.SetOperation(ctx, "/com.diulo.api.user/login")
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.Login(ctx, req.(*LoginRequest))
})
out, err := h(newCtx, &in)
if err != nil {
return err
}
reply := out.(*LoginResponse)
return ctx.Result(200, reply)
}
}