Skip to content

Commit

Permalink
feat: Move all the common APIs into go-mod-bootstrap
Browse files Browse the repository at this point in the history
related: edgexfoundry/go-mod-bootstrap#478

Signed-off-by: Ginny Guan <ginny@iotechsys.com>
  • Loading branch information
jinlinGuan committed Jul 14, 2023
1 parent fa614b6 commit dd2e2b4
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 343 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ require (
gopkg.in/yaml.v3 v3.0.1
)

replace github.com/edgexfoundry/go-mod-bootstrap/v3 => github.com/jinlinGuan/go-mod-bootstrap/v3 v3.0.0-20230714101502-6ab2fd8dcc73

require (
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik=
github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.1.0-dev.5 h1:KdAEhHb1ETPLfhnrz/pKra7usnv6PVwXJBmHE+yUa4U=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.1.0-dev.5/go.mod h1:EHev55Vr5Xyhz1IbVbVngo+i0E1Cbb/Qia7ocHqE4qE=
github.com/edgexfoundry/go-mod-configuration/v3 v3.1.0-dev.3 h1:xWyraOW+RtFwIO+DnCWBKoaa5w1ZX8vRf91zBa2Ll8c=
github.com/edgexfoundry/go-mod-configuration/v3 v3.1.0-dev.3/go.mod h1:yaxBuJh45+VxXX+nSt/Q+1gGEk4/BDe9edYWm8aEtfg=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.1.0-dev.2 h1:H3ls1vyxCv6pigZ/RZlRhj9lUTQq7CiT5/dnZRsgVmQ=
Expand Down Expand Up @@ -132,6 +130,8 @@ github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY
github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jinlinGuan/go-mod-bootstrap/v3 v3.0.0-20230714101502-6ab2fd8dcc73 h1:2hUUJQ9d57ZUZGGlmpwWM352DyBO5q2wn2uiduVcojE=
github.com/jinlinGuan/go-mod-bootstrap/v3 v3.0.0-20230714101502-6ab2fd8dcc73/go.mod h1:EHev55Vr5Xyhz1IbVbVngo+i0E1Cbb/Qia7ocHqE4qE=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
Expand Down
12 changes: 5 additions & 7 deletions internal/core/command/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
package command

import (
"net/http"

"github.com/edgexfoundry/edgex-go"
"github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/container"
"github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/controller"
"github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/handlers"
"github.com/edgexfoundry/go-mod-bootstrap/v3/di"
"github.com/edgexfoundry/go-mod-core-contracts/v3/common"
"github.com/gorilla/mux"
"net/http"

commandController "github.com/edgexfoundry/edgex-go/internal/core/command/controller/http"
commonController "github.com/edgexfoundry/edgex-go/internal/pkg/controller/http"
"github.com/edgexfoundry/edgex-go/internal/pkg/correlation"
)

Expand All @@ -29,10 +29,8 @@ func LoadRestRoutes(r *mux.Router, dic *di.Container, serviceName string) {
authenticationHook := handlers.AutoConfigAuthenticationFunc(secretProvider, lc)

// Common
cc := commonController.NewCommonController(dic, serviceName)
r.HandleFunc(common.ApiPingRoute, cc.Ping).Methods(http.MethodGet) // Health check is always unauthenticated
r.HandleFunc(common.ApiVersionRoute, authenticationHook(cc.Version)).Methods(http.MethodGet)
r.HandleFunc(common.ApiConfigRoute, authenticationHook(cc.Config)).Methods(http.MethodGet)
cc := controller.NewCommonController(dic, r, serviceName, edgex.Version)
cc.LoadCommonRoutes()

// Command
cmd := commandController.NewCommandController(dic)
Expand Down
9 changes: 4 additions & 5 deletions internal/core/data/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ package data
import (
"net/http"

"github.com/edgexfoundry/edgex-go"
"github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/container"
"github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/controller"
"github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/handlers"
"github.com/edgexfoundry/go-mod-bootstrap/v3/di"
"github.com/gorilla/mux"

"github.com/edgexfoundry/go-mod-core-contracts/v3/common"

dataController "github.com/edgexfoundry/edgex-go/internal/core/data/controller/http"
commonController "github.com/edgexfoundry/edgex-go/internal/pkg/controller/http"
"github.com/edgexfoundry/edgex-go/internal/pkg/correlation"
)

Expand All @@ -30,10 +31,8 @@ func LoadRestRoutes(r *mux.Router, dic *di.Container, serviceName string) {
authenticationHook := handlers.AutoConfigAuthenticationFunc(secretProvider, lc)

// Common
cc := commonController.NewCommonController(dic, serviceName)
r.HandleFunc(common.ApiPingRoute, cc.Ping).Methods(http.MethodGet) // Health check is always unauthenticated
r.HandleFunc(common.ApiVersionRoute, authenticationHook(cc.Version)).Methods(http.MethodGet)
r.HandleFunc(common.ApiConfigRoute, authenticationHook(cc.Config)).Methods(http.MethodGet)
cc := controller.NewCommonController(dic, r, serviceName, edgex.Version)
cc.LoadCommonRoutes()

// Events
ec := dataController.NewEventController(dic)
Expand Down
9 changes: 4 additions & 5 deletions internal/core/metadata/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ package metadata
import (
"net/http"

"github.com/edgexfoundry/edgex-go"
"github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/container"
"github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/controller"
"github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/handlers"
"github.com/edgexfoundry/go-mod-bootstrap/v3/di"
"github.com/gorilla/mux"

"github.com/edgexfoundry/go-mod-core-contracts/v3/common"

metadataController "github.com/edgexfoundry/edgex-go/internal/core/metadata/controller/http"
commonController "github.com/edgexfoundry/edgex-go/internal/pkg/controller/http"
"github.com/edgexfoundry/edgex-go/internal/pkg/correlation"
)

Expand All @@ -30,10 +31,8 @@ func LoadRestRoutes(r *mux.Router, dic *di.Container, serviceName string) {
authenticationHook := handlers.AutoConfigAuthenticationFunc(secretProvider, lc)

// Common
cc := commonController.NewCommonController(dic, serviceName)
r.HandleFunc(common.ApiPingRoute, cc.Ping).Methods(http.MethodGet) // Health check is always unauthenticated
r.HandleFunc(common.ApiVersionRoute, authenticationHook(cc.Version)).Methods(http.MethodGet)
r.HandleFunc(common.ApiConfigRoute, authenticationHook(cc.Config)).Methods(http.MethodGet)
cc := controller.NewCommonController(dic, r, serviceName, edgex.Version)
cc.LoadCommonRoutes()

// Units of Measure
uc := metadataController.NewUnitOfMeasureController(dic)
Expand Down
41 changes: 0 additions & 41 deletions internal/pkg/application/secret.go

This file was deleted.

102 changes: 0 additions & 102 deletions internal/pkg/controller/http/common.go

This file was deleted.

41 changes: 0 additions & 41 deletions internal/pkg/controller/http/secret.go

This file was deleted.

Loading

0 comments on commit dd2e2b4

Please sign in to comment.