NOISSUE - Rm users http package (#1256)

* NOISSUE - Mv users http gokit layers to http package

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Remove users/api/http dir

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
This commit is contained in:
Manuel Imperiale 2020-10-16 18:00:24 +02:00 committed by GitHub
parent 86fe3f7cdb
commit 420b598ac7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 24 deletions

View File

@ -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))
}
}

View File

@ -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)
}

View File

@ -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
}
}

View File

@ -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)
}

View File

@ -1,5 +0,0 @@
// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
// Package http contains implementation of users service HTTP API.
package http

View File

@ -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),
}