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.

124 lines
3.7 KiB

2 years ago
package user
import (
2 years ago
"git.diulo.com/mogfee/kit/transport/http"
2 years ago
"git.diulo.com/mogfee/kit/middleware/jwt"
2 years ago
"context"
2 years ago
)
type UserHTTPServer interface {
2 years ago
List(context.Context, *Request) (*Response, error)
All(context.Context, *Request) (*Response, error)
2 years ago
Auto(context.Context, *Request) (*Response, error)
2 years ago
LoginWithList(context.Context, *Request) (*Response, error)
Login(context.Context, *Request) (*Response, error)
2 years ago
}
func RegisterUserHTTPServer(s *http.Server, srv UserServer) {
r := s.Route("/")
r.GET("/api/v1/user/list", _User_List0_HTTP_Handler(srv))
2 years ago
r.GET("/api/v1/user/all", _User_All0_HTTP_Handler(srv))
2 years ago
r.GET("/api/v1/user/auto", _User_Auto0_HTTP_Handler(srv))
2 years ago
r.GET("/api/v1/user/login_list", _User_LoginWithList0_HTTP_Handler(srv))
2 years ago
r.GET("/api/v1/user/login", _User_Login0_HTTP_Handler(srv))
2 years ago
}
func _User_List0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
2 years ago
var in Request
2 years ago
//user:list
2 years ago
var newCtx context.Context = ctx
2 years ago
newCtx = jwt.SetAuthKeyContext(newCtx, "user:list")
newCtx = jwt.SetNeedAuthContext(newCtx, true)
2 years ago
if err := ctx.BindQuery(&in); err != nil {
return err
}
2 years ago
http.SetOperation(ctx, "/com.diulo.api.user/list")
2 years ago
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
2 years ago
return srv.List(ctx, req.(*Request))
2 years ago
})
2 years ago
out, err := h(newCtx, &in)
2 years ago
if err != nil {
return err
}
2 years ago
reply := out.(*Response)
2 years ago
return ctx.Result(200, reply)
}
}
2 years ago
func _User_All0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error {
2 years ago
return func(ctx http.Context) error {
2 years ago
var in Request
2 years ago
var newCtx context.Context = ctx
2 years ago
newCtx = jwt.SetNeedAuthContext(newCtx, true)
2 years ago
if err := ctx.BindQuery(&in); err != nil {
2 years ago
return err
}
2 years ago
http.SetOperation(ctx, "/com.diulo.api.user/all")
2 years ago
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
2 years ago
return srv.All(ctx, req.(*Request))
2 years ago
})
out, err := h(newCtx, &in)
if err != nil {
return err
}
2 years ago
reply := out.(*Response)
2 years ago
return ctx.Result(200, reply)
}
}
2 years ago
func _User_Auto0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error {
2 years ago
return func(ctx http.Context) error {
2 years ago
var in Request
2 years ago
var newCtx context.Context = ctx
if err := ctx.BindQuery(&in); err != nil {
return err
}
2 years ago
http.SetOperation(ctx, "/com.diulo.api.user/auto")
2 years ago
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
2 years ago
return srv.Auto(ctx, req.(*Request))
2 years ago
})
out, err := h(newCtx, &in)
if err != nil {
return err
}
2 years ago
reply := out.(*Response)
2 years ago
return ctx.Result(200, reply)
}
}
2 years ago
func _User_LoginWithList0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error {
2 years ago
return func(ctx http.Context) error {
2 years ago
var in Request
2 years ago
var newCtx context.Context = ctx
if err := ctx.BindQuery(&in); err != nil {
return err
}
2 years ago
http.SetOperation(ctx, "/com.diulo.api.user/loginWithList")
2 years ago
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
2 years ago
return srv.LoginWithList(ctx, req.(*Request))
2 years ago
})
out, err := h(newCtx, &in)
if err != nil {
return err
}
2 years ago
reply := out.(*Response)
2 years ago
return ctx.Result(200, reply)
}
}
2 years ago
func _User_Login0_HTTP_Handler(srv UserHTTPServer) func(ctx http.Context) error {
2 years ago
return func(ctx http.Context) error {
2 years ago
var in Request
2 years ago
var newCtx context.Context = ctx
if err := ctx.BindQuery(&in); err != nil {
return err
}
2 years ago
http.SetOperation(ctx, "/com.diulo.api.user/login")
2 years ago
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
2 years ago
return srv.Login(ctx, req.(*Request))
2 years ago
})
out, err := h(newCtx, &in)
if err != nil {
return err
}
2 years ago
reply := out.(*Response)
2 years ago
return ctx.Result(200, reply)
}
}