Skip to content

Commit

Permalink
Merge pull request #4608 from jinlinGuan/bootstrap-issue-478
Browse files Browse the repository at this point in the history
feat: Move all the common APIs into go-mod-bootstrap
  • Loading branch information
cloudxxx8 authored Jul 19, 2023
2 parents 1e69c56 + b3c3aff commit e66fa62
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 339 deletions.
8 changes: 3 additions & 5 deletions internal/core/command/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ 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"

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 +30,7 @@ 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)
_ = controller.NewCommonController(dic, r, serviceName, edgex.Version)

// Command
cmd := commandController.NewCommandController(dic)
Expand Down
8 changes: 3 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,7 @@ 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)
_ = controller.NewCommonController(dic, r, serviceName, edgex.Version)

// Events
ec := dataController.NewEventController(dic)
Expand Down
8 changes: 3 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,7 @@ 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)
_ = controller.NewCommonController(dic, r, serviceName, edgex.Version)

// 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.

122 changes: 0 additions & 122 deletions internal/pkg/controller/http/secret_test.go

This file was deleted.

Loading

0 comments on commit e66fa62

Please sign in to comment.