Merge pull request #18 from moul/dev/moul/cleanup

Remove user.logout method
This commit is contained in:
Manfred Touron 2016-12-13 17:42:09 +01:00 committed by GitHub
commit ff7e469a05
7 changed files with 17 additions and 174 deletions

View File

@ -1,6 +1,9 @@
language: go
go: 1.7.x
install: wget https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/.travis/install-protoc.sh && chmod +x install-protoc.sh && ./install-protoc.sh 3.1.0
install:
- wget https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/.travis/install-protoc.sh && chmod +x install-protoc.sh && ./install-protoc.sh 3.1.0
- go get github.com/gogo/protobuf/protoc-gen-gogo
- go get ./...
script:
- make install
- make test

View File

@ -11,8 +11,6 @@ var _ = fmt.Errorf
type Endpoints struct {
LoginEndpoint endpoint.Endpoint
LogoutEndpoint endpoint.Endpoint
}
func (e *Endpoints) Login(ctx context.Context, in *pb.LoginRequest) (*pb.LoginResponse, error) {
@ -23,14 +21,6 @@ func (e *Endpoints) Login(ctx context.Context, in *pb.LoginRequest) (*pb.LoginRe
return out.(*pb.LoginResponse), err
}
func (e *Endpoints) Logout(ctx context.Context, in *pb.LogoutRequest) (*pb.LogoutResponse, error) {
out, err := e.LogoutEndpoint(ctx, in)
if err != nil {
return &pb.LogoutResponse{ErrMsg: err.Error()}, err
}
return out.(*pb.LogoutResponse), err
}
func MakeLoginEndpoint(svc pb.SessionServiceServer) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
req := request.(*pb.LoginRequest)
@ -42,22 +32,9 @@ func MakeLoginEndpoint(svc pb.SessionServiceServer) endpoint.Endpoint {
}
}
func MakeLogoutEndpoint(svc pb.SessionServiceServer) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
req := request.(*pb.LogoutRequest)
rep, err := svc.Logout(ctx, req)
if err != nil {
return &pb.LogoutResponse{ErrMsg: err.Error()}, err
}
return rep, nil
}
}
func MakeEndpoints(svc pb.SessionServiceServer) Endpoints {
return Endpoints{
LoginEndpoint: MakeLoginEndpoint(svc),
LogoutEndpoint: MakeLogoutEndpoint(svc),
}
}

View File

@ -11,8 +11,6 @@ It is generated from these files:
It has these top-level messages:
LoginRequest
LoginResponse
LogoutRequest
LogoutResponse
*/
package session
@ -84,43 +82,9 @@ func (m *LoginResponse) GetErrMsg() string {
return ""
}
type LogoutRequest struct {
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
}
func (m *LogoutRequest) Reset() { *m = LogoutRequest{} }
func (m *LogoutRequest) String() string { return proto.CompactTextString(m) }
func (*LogoutRequest) ProtoMessage() {}
func (*LogoutRequest) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{2} }
func (m *LogoutRequest) GetToken() string {
if m != nil {
return m.Token
}
return ""
}
type LogoutResponse struct {
ErrMsg string `protobuf:"bytes,1,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"`
}
func (m *LogoutResponse) Reset() { *m = LogoutResponse{} }
func (m *LogoutResponse) String() string { return proto.CompactTextString(m) }
func (*LogoutResponse) ProtoMessage() {}
func (*LogoutResponse) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{3} }
func (m *LogoutResponse) GetErrMsg() string {
if m != nil {
return m.ErrMsg
}
return ""
}
func init() {
proto.RegisterType((*LoginRequest)(nil), "session.LoginRequest")
proto.RegisterType((*LoginResponse)(nil), "session.LoginResponse")
proto.RegisterType((*LogoutRequest)(nil), "session.LogoutRequest")
proto.RegisterType((*LogoutResponse)(nil), "session.LogoutResponse")
}
// Reference imports to suppress errors if they are not otherwise used.
@ -135,7 +99,6 @@ const _ = grpc.SupportPackageIsVersion4
type SessionServiceClient interface {
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error)
}
type sessionServiceClient struct {
@ -155,20 +118,10 @@ func (c *sessionServiceClient) Login(ctx context.Context, in *LoginRequest, opts
return out, nil
}
func (c *sessionServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) {
out := new(LogoutResponse)
err := grpc.Invoke(ctx, "/session.SessionService/Logout", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for SessionService service
type SessionServiceServer interface {
Login(context.Context, *LoginRequest) (*LoginResponse, error)
Logout(context.Context, *LogoutRequest) (*LogoutResponse, error)
}
func RegisterSessionServiceServer(s *grpc.Server, srv SessionServiceServer) {
@ -193,24 +146,6 @@ func _SessionService_Login_Handler(srv interface{}, ctx context.Context, dec fun
return interceptor(ctx, in, info, handler)
}
func _SessionService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LogoutRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SessionServiceServer).Logout(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/session.SessionService/Logout",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SessionServiceServer).Logout(ctx, req.(*LogoutRequest))
}
return interceptor(ctx, in, info, handler)
}
var _SessionService_serviceDesc = grpc.ServiceDesc{
ServiceName: "session.SessionService",
HandlerType: (*SessionServiceServer)(nil),
@ -219,10 +154,6 @@ var _SessionService_serviceDesc = grpc.ServiceDesc{
MethodName: "Login",
Handler: _SessionService_Login_Handler,
},
{
MethodName: "Logout",
Handler: _SessionService_Logout_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "services/session/session.proto",
@ -231,20 +162,17 @@ var _SessionService_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("services/session/session.proto", fileDescriptorSession) }
var fileDescriptorSession = []byte{
// 231 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x50, 0xcb, 0x4a, 0xc5, 0x30,
0x10, 0x35, 0xc2,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fe, 0xd8, 0xf9, 0xce, 0x5b,
0xac, 0xff, 0xfc, 0x27, 0xf2, 0x43, 0x36, 0x75, 0x7e, 0xf1, 0x11, 0x00, 0x00, 0xff, 0xff, 0xc7,
0x91, 0x50, 0x79, 0x95, 0x01, 0x00, 0x00,
// 188 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x4e, 0x2d, 0x2a,
0xcb, 0x4c, 0x4e, 0x2d, 0xd6, 0x2f, 0x4e, 0x2d, 0x2e, 0xce, 0xcc, 0xcf, 0x83, 0xd1, 0x7a, 0x05,
0x45, 0xf9, 0x25, 0xf9, 0x42, 0xec, 0x50, 0xae, 0x92, 0x1b, 0x17, 0x8f, 0x4f, 0x7e, 0x7a, 0x66,
0x5e, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, 0x14, 0x17, 0x47, 0x69, 0x71, 0x6a, 0x51,
0x5e, 0x62, 0x6e, 0xaa, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x9c, 0x0f, 0x92, 0x2b, 0x48,
0x2c, 0x2e, 0x2e, 0xcf, 0x2f, 0x4a, 0x91, 0x60, 0x82, 0xc8, 0xc1, 0xf8, 0x4a, 0x76, 0x5c, 0xbc,
0x50, 0x73, 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0x44, 0xb8, 0x58, 0x4b, 0xf2, 0xb3, 0x53,
0xf3, 0xa0, 0xa6, 0x40, 0x38, 0x42, 0xe2, 0x5c, 0xec, 0xa9, 0x45, 0x45, 0xf1, 0xb9, 0xc5, 0xe9,
0x50, 0x13, 0xd8, 0x52, 0x8b, 0x8a, 0x7c, 0x8b, 0xd3, 0x8d, 0xbc, 0xb8, 0xf8, 0x82, 0x21, 0x4e,
0x0a, 0x86, 0xb8, 0x5c, 0xc8, 0x82, 0x8b, 0x15, 0x6c, 0xa2, 0x90, 0xa8, 0x1e, 0xcc, 0xed, 0xc8,
0x2e, 0x95, 0x12, 0x43, 0x17, 0x86, 0x58, 0xac, 0xc4, 0x90, 0xc4, 0x06, 0xf6, 0xa3, 0x31, 0x20,
0x00, 0x00, 0xff, 0xff, 0x29, 0x3f, 0x91, 0xc7, 0x05, 0x01, 0x00, 0x00,
}

View File

@ -23,21 +23,11 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoint.Endpoints) pb.Sessio
encodeLoginResponse,
options...,
),
logout: grpctransport.NewServer(
ctx,
endpoints.LogoutEndpoint,
decodeLogoutRequest,
encodeLogoutResponse,
options...,
),
}
}
type grpcServer struct {
login grpctransport.Handler
logout grpctransport.Handler
}
func (s *grpcServer) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error) {
@ -56,20 +46,3 @@ func encodeLoginResponse(ctx context.Context, response interface{}) (interface{}
resp := response.(*pb.LoginResponse)
return resp, nil
}
func (s *grpcServer) Logout(ctx context.Context, req *pb.LogoutRequest) (*pb.LogoutResponse, error) {
_, rep, err := s.logout.ServeGRPC(ctx, req)
if err != nil {
return nil, err
}
return rep.(*pb.LogoutResponse), nil
}
func decodeLogoutRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) {
return grpcReq, nil
}
func encodeLogoutResponse(ctx context.Context, response interface{}) (interface{}, error) {
resp := response.(*pb.LogoutResponse)
return resp, nil
}

View File

@ -34,35 +34,10 @@ func encodeLoginResponse(ctx context.Context, w http.ResponseWriter, response in
return json.NewEncoder(w).Encode(response)
}
func MakeLogoutHandler(ctx context.Context, svc pb.SessionServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
return httptransport.NewServer(
ctx,
endpoint,
decodeLogoutRequest,
encodeLogoutResponse,
[]httptransport.ServerOption{}...,
)
}
func decodeLogoutRequest(ctx context.Context, r *http.Request) (interface{}, error) {
var req pb.LogoutRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
return nil, err
}
return &req, nil
}
func encodeLogoutResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {
return json.NewEncoder(w).Encode(response)
}
func RegisterHandlers(ctx context.Context, svc pb.SessionServiceServer, mux *http.ServeMux, endpoints endpoints.Endpoints) error {
log.Println("new HTTP endpoint: \"/Login\" (service=Session)")
mux.Handle("/Login", MakeLoginHandler(ctx, svc, endpoints.LoginEndpoint))
log.Println("new HTTP endpoint: \"/Logout\" (service=Session)")
mux.Handle("/Logout", MakeLogoutHandler(ctx, svc, endpoints.LogoutEndpoint))
return nil
}

View File

@ -17,7 +17,3 @@ func New() pb.SessionServiceServer {
func (svc *Service) Login(ctx context.Context, in *pb.LoginRequest) (*pb.LoginResponse, error) {
return nil, fmt.Errorf("not implemented")
}
func (svc *Service) Logout(ctx context.Context, in *pb.LogoutRequest) (*pb.LogoutResponse, error) {
return nil, fmt.Errorf("not implemented")
}

View File

@ -4,7 +4,6 @@ package session;
service SessionService {
rpc Login(LoginRequest) returns (LoginResponse) {}
rpc Logout(LogoutRequest) returns (LogoutResponse) {}
}
message LoginRequest {
@ -16,11 +15,3 @@ message LoginResponse {
string token = 1;
string err_msg = 2;
}
message LogoutRequest {
string token = 1;
}
message LogoutResponse {
string err_msg = 1;
}