Repository: mainflux/mainflux
Pull request #1256 (2020-10-16 11:09:46)

NOISSUE - Rm users http package
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>



Patch:
diff --git a/cmd/users/main.go b/cmd/users/main.go
index 8b31897c..49b64d7a 100644
--- a/cmd/users/main.go
+++ b/cmd/users/main.go
@@ -330,9 +330,9 @@ func startHTTPServer(tracer opentracing.Tracer, svc users.Service, port string,
 	p := fmt.Sprintf(":%s", port)
 	if certFile != "" || keyFile != "" {
 		logger.Info(fmt.Sprintf("Users service started using https, cert %s key %s, exposed port %s", certFile, keyFile, port))
-		errs <- http.ListenAndServeTLS(p, certFile, keyFile, api.MakeHandler(svc, tracer, logger))
+		errs <- http.ListenAndServeTLS(p, certFile, keyFile, api.MakeHandler(svc, tracer))
 	} else {
 		logger.Info(fmt.Sprintf("Users service started using http, exposed port %s", port))
-		errs <- http.ListenAndServe(p, api.MakeHandler(svc, tracer, logger))
+		errs <- http.ListenAndServe(p, api.MakeHandler(svc, tracer))
 	}
 }
diff --git a/users/api/endpoint.go b/users/api/endpoint.go
index 94573a34..a574ffeb 100644
--- a/users/api/endpoint.go
+++ b/users/api/endpoint.go
@@ -24,7 +24,7 @@ func registrationEndpoint(svc users.Service) endpoint.Endpoint {
 			ID:      uid,
 			created: true,
 		}
-		logger.Info("User successfully registered")
+
 		return ucr, nil
 	}
 }
@@ -51,7 +51,7 @@ func passwordResetRequestEndpoint(svc users.Service) endpoint.Endpoint {
 			return nil, err
 		}
 		res.Msg = MailSent
-		logger.Info("User made a password reset request")
+
 		return res, nil
 	}
 }
@@ -134,7 +134,7 @@ func loginEndpoint(svc users.Service) endpoint.Endpoint {
 		if err != nil {
 			return nil, err
 		}
-		logger.Info("User logged in")
+
 		return tokenRes{token}, nil
 	}
 }
@@ -163,7 +163,7 @@ func createGroupEndpoint(svc users.Service) endpoint.Endpoint {
 			ParentID:    saved.ParentID,
 			created:     true,
 		}
-		logger.Info("Group: " + res.Name + " is created")
+
 		return res, nil
 	}
 }
diff --git a/users/api/http/doc.go b/users/api/http/doc.go
deleted file mode 100644
index d6735e60..00000000
--- a/users/api/http/doc.go
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright (c) Mainflux
-// SPDX-License-Identifier: Apache-2.0
-
-// Package http contains implementation of users service HTTP API.
-package http
diff --git a/users/api/transport.go b/users/api/transport.go
index 491e2dff..24179d9d 100644
--- a/users/api/transport.go
+++ b/users/api/transport.go
@@ -17,7 +17,6 @@ import (
 	kithttp "github.com/go-kit/kit/transport/http"
 	"github.com/go-zoo/bone"
 	"github.com/mainflux/mainflux"
-	log "github.com/mainflux/mainflux/logger"
 	"github.com/mainflux/mainflux/users"
 	opentracing "github.com/opentracing/opentracing-go"
 	"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -43,13 +42,10 @@ var (
 
 	// ErrFailedDecode indicates failed to decode request body
 	ErrFailedDecode = errors.New("failed to decode request body")
-	logger          log.Logger
 )
 
 // MakeHandler returns a HTTP handler for API endpoints.
-func MakeHandler(svc users.Service, tracer opentracing.Tracer, l log.Logger) http.Handler {
-	logger = l
-
+func MakeHandler(svc users.Service, tracer opentracing.Tracer) http.Handler {
 	opts := []kithttp.ServerOption{
 		kithttp.ServerErrorEncoder(encodeError),
 	}


Test patch:
diff --git a/pkg/sdk/go/users_test.go b/pkg/sdk/go/users_test.go
index 512bea84..7c6bd4df 100644
--- a/pkg/sdk/go/users_test.go
+++ b/pkg/sdk/go/users_test.go
@@ -8,11 +8,9 @@ import (
 	"fmt"
 	"net/http"
 	"net/http/httptest"
-	"os"
 	"testing"
 
 	"github.com/mainflux/mainflux"
-	log "github.com/mainflux/mainflux/logger"
 	sdk "github.com/mainflux/mainflux/pkg/sdk/go"
 	"github.com/mainflux/mainflux/users"
 	"github.com/mainflux/mainflux/users/api"
@@ -36,8 +34,7 @@ func newUserService() users.Service {
 }
 
 func newUserServer(svc users.Service) *httptest.Server {
-	logger, _ := log.New(os.Stdout, log.Info.String())
-	mux := api.MakeHandler(svc, mocktracer.New(), logger)
+	mux := api.MakeHandler(svc, mocktracer.New())
 	return httptest.NewServer(mux)
 }
 
diff --git a/users/api/endpoint_test.go b/users/api/endpoint_test.go
index 6aa4b732..dd1c069b 100644
--- a/users/api/endpoint_test.go
+++ b/users/api/endpoint_test.go
@@ -11,12 +11,10 @@ import (
 	"io/ioutil"
 	"net/http"
 	"net/http/httptest"
-	"os"
 	"strings"
 	"testing"
 
 	"github.com/mainflux/mainflux"
-	log "github.com/mainflux/mainflux/logger"
 	"github.com/mainflux/mainflux/users"
 	"github.com/mainflux/mainflux/users/api"
 	"github.com/mainflux/mainflux/users/bcrypt"
@@ -77,8 +75,7 @@ func newService() users.Service {
 }
 
 func newServer(svc users.Service) *httptest.Server {
-	logger, _ := log.New(os.Stdout, log.Info.String())
-	mux := api.MakeHandler(svc, mocktracer.New(), logger)
+	mux := api.MakeHandler(svc, mocktracer.New())
 	return httptest.NewServer(mux)
 }