package user import ( "git.diulo.com/mogfee/kit/middleware/jwt" "context" "git.diulo.com/mogfee/kit/transport/http" ) type UserHTTPServer interface { List(context.Context, *Request) (*Response, error) All(context.Context, *Request) (*Response, error) Auto(context.Context, *Request) (*Response, error) LoginWithList(context.Context, *Request) (*Response, error) Login(context.Context, *Request) (*Response, error) Login1(context.Context, *Request) (*Response, 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/all", _User_All0_HTTP_Handler(srv)) r.GET("/api/v1/user/auto", _User_Auto0_HTTP_Handler(srv)) r.GET("/api/v1/user/login_list", _User_LoginWithList0_HTTP_Handler(srv)) r.GET("/api/v1/user/login", _User_Login0_HTTP_Handler(srv)) r.POST("/api/v1/user/login1", _User_Login10_HTTP_Handler(srv)) } func _User_List0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in Request //user:list var newCtx context.Context = ctx newCtx = jwt.SetAuthKeyContext(newCtx, "user:list") newCtx = jwt.SetNeedAuthContext(newCtx, true) 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.(*Request)) }) out, err := h(newCtx, &in) if err != nil { return err } reply := out.(*Response) return ctx.Result(200, reply) } } func _User_All0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in Request var newCtx context.Context = ctx newCtx = jwt.SetNeedAuthContext(newCtx, true) if err := ctx.BindQuery(&in); err != nil { return err } http.SetOperation(ctx, "/com.diulo.api.user/all") h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.All(ctx, req.(*Request)) }) out, err := h(newCtx, &in) if err != nil { return err } reply := out.(*Response) return ctx.Result(200, reply) } } func _User_Auto0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in Request var newCtx context.Context = ctx if err := ctx.BindQuery(&in); err != nil { return err } http.SetOperation(ctx, "/com.diulo.api.user/auto") h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Auto(ctx, req.(*Request)) }) out, err := h(newCtx, &in) if err != nil { return err } reply := out.(*Response) return ctx.Result(200, reply) } } func _User_LoginWithList0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in Request var newCtx context.Context = ctx if err := ctx.BindQuery(&in); err != nil { return err } http.SetOperation(ctx, "/com.diulo.api.user/loginWithList") h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.LoginWithList(ctx, req.(*Request)) }) out, err := h(newCtx, &in) if err != nil { return err } reply := out.(*Response) 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 Request var newCtx context.Context = ctx 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.(*Request)) }) out, err := h(newCtx, &in) if err != nil { return err } reply := out.(*Response) return ctx.Result(200, reply) } } func _User_Login10_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in Request var newCtx context.Context = ctx if err := ctx.Bind(&in); err != nil { return err } http.SetOperation(ctx, "/com.diulo.api.user/login1") h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Login1(ctx, req.(*Request)) }) out, err := h(newCtx, &in) if err != nil { return err } reply := out.(*Response) return ctx.Result(200, reply) } }