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