|
@@ -2,7 +2,6 @@ package service
|
|
|
|
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
- "csacred/define/router"
|
|
|
|
|
|
|
|
"git.chuangxin1.com/csacred/toolkit/example/cuser/define"
|
|
"git.chuangxin1.com/csacred/toolkit/example/cuser/define"
|
|
"git.chuangxin1.com/csacred/toolkit/http"
|
|
"git.chuangxin1.com/csacred/toolkit/http"
|
|
@@ -11,10 +10,7 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
// API gateway factory
|
|
// API gateway factory
|
|
-func factory(
|
|
|
|
- ctx context.Context,
|
|
|
|
- instancer *consulsd.Instancer,
|
|
|
|
- logger log.Logger) Endpoints {
|
|
|
|
|
|
+func factory(ctx context.Context, instancer *consulsd.Instancer, logger log.Logger) Endpoints {
|
|
e := Endpoints{}
|
|
e := Endpoints{}
|
|
|
|
|
|
var lb http.LoadBalancer
|
|
var lb http.LoadBalancer
|
|
@@ -42,18 +38,16 @@ func factory(
|
|
func endpointHanders(endpoints Endpoints) []http.EndpointRouter {
|
|
func endpointHanders(endpoints Endpoints) []http.EndpointRouter {
|
|
var handers []http.EndpointRouter
|
|
var handers []http.EndpointRouter
|
|
|
|
|
|
- handers = append(handers, http.GetEndpointRouter(router.RouteUserGetProfile, DecodeGetUserProfileRequest, http.WriteCtxJSON, endpoints.UserProfileEndpoint))
|
|
|
|
- handers = append(handers, http.GetEndpointRouter(router.RouteUserGetList, DecodeGetUserListRequest, http.WriteCtxJSON, endpoints.UserListEndpoint))
|
|
|
|
- handers = append(handers, http.PostEndpointRouter(router.RouteUserPostSignIn, DecodePostUserSignInRequest, http.WriteCtxJSON, endpoints.UserSignInEndpoint))
|
|
|
|
- handers = append(handers, http.PostEndpointRouter(router.RouteUserPostChangePwd, DecodePostUserChangePwdRequest, http.WriteCtxJSON, endpoints.UserChangePwdEndpoint))
|
|
|
|
|
|
+ handers = append(handers, http.GetEndpointRouter(define.RouteUserGetProfile, DecodeGetUserProfileRequest, http.WriteCtxJSON, endpoints.UserProfileEndpoint))
|
|
|
|
+ handers = append(handers, http.GetEndpointRouter(define.RouteUserGetList, DecodeGetUserListRequest, http.WriteCtxJSON, endpoints.UserListEndpoint))
|
|
|
|
+ handers = append(handers, http.PostEndpointRouter(define.RouteUserPostSignIn, DecodePostUserSignInRequest, http.WriteCtxJSON, endpoints.UserSignInEndpoint))
|
|
|
|
+ handers = append(handers, http.PostEndpointRouter(define.RouteUserPostChangePwd, DecodePostUserChangePwdRequest, http.WriteCtxJSON, endpoints.UserChangePwdEndpoint))
|
|
|
|
|
|
return handers
|
|
return handers
|
|
}
|
|
}
|
|
|
|
|
|
// GenServiceHandler service handler
|
|
// GenServiceHandler service handler
|
|
-func GenServiceHandler(
|
|
|
|
- s UserServicer,
|
|
|
|
- logger log.Logger) []http.RouterHandler {
|
|
|
|
|
|
+func GenServiceHandler(s UserServicer, logger log.Logger) []http.RouterHandler {
|
|
var handers []http.RouterHandler
|
|
var handers []http.RouterHandler
|
|
|
|
|
|
e := GenServerEndpoints(s)
|
|
e := GenServerEndpoints(s)
|
|
@@ -65,10 +59,7 @@ func GenServiceHandler(
|
|
}
|
|
}
|
|
|
|
|
|
// GenGatewayHandlers gateway handlers
|
|
// GenGatewayHandlers gateway handlers
|
|
-func GenGatewayHandlers(
|
|
|
|
- ctx context.Context,
|
|
|
|
- instancer *consulsd.Instancer,
|
|
|
|
- logger log.Logger) []http.RouterHandler {
|
|
|
|
|
|
+func GenGatewayHandlers(ctx context.Context, instancer *consulsd.Instancer, logger log.Logger) []http.RouterHandler {
|
|
var handers []http.RouterHandler
|
|
var handers []http.RouterHandler
|
|
|
|
|
|
e := factory(ctx, instancer, logger)
|
|
e := factory(ctx, instancer, logger)
|