Skip to content

Commit

Permalink
feat: Add CORS support (#983)
Browse files Browse the repository at this point in the history
Added CORS support enabled in go-mod-bootstrap

closes #982

Signed-off-by: Leonard Goodell <leonard.goodell@intel.com>
  • Loading branch information
Lenny Goodell authored Oct 21, 2021
1 parent b877746 commit 2f5b3cf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
bitbucket.org/bertimus9/systemstat v0.0.0-20180207000608-0eeff89b0690
github.com/diegoholiveira/jsonlogic v1.0.1-0.20200220175622-ab7989be08b9
github.com/eclipse/paho.mqtt.golang v1.3.5
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.0.1-dev.13
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.0.1-dev.14
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.0.1-dev.23
github.com/edgexfoundry/go-mod-messaging/v2 v2.0.2-dev.6
github.com/edgexfoundry/go-mod-registry/v2 v2.0.1-dev.8
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y=
github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.0.1-dev.13 h1:LvbGywemQcG2xgZi6MaK63b5G+Vt1SF3tP7Lly6DdVs=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.0.1-dev.13/go.mod h1:FUTBZgP4hMyJOetw3WkM6trUs2SG3AceO3NAZhZyG9M=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.0.1-dev.14 h1:vTV7AM2HnP5HiIPzED7Cd1PAXsKpWjj6m/nP39L4fM4=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.0.1-dev.14/go.mod h1:84xs+nDgmAu8X2qTWsj9GTkgcIQDzS+O/O6RjvFE38M=
github.com/edgexfoundry/go-mod-configuration/v2 v2.0.1-dev.5 h1:icE1aVlX7I3SJ0qPqZJchCr2JLe2TMRZlUMIM2qoivo=
github.com/edgexfoundry/go-mod-configuration/v2 v2.0.1-dev.5/go.mod h1:MvHit0MxBXN4bC8LL0NZRsw72ByRE1XwtVLQP9C+2vg=
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.0.0/go.mod h1:pfXURRetgIto0GR0sCjDrfa71hqJ1wxmQWi/mOzWfWU=
Expand Down Expand Up @@ -148,7 +148,6 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
Expand Down
4 changes: 4 additions & 0 deletions internal/webserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"net/http"
"time"

"github.com/edgexfoundry/go-mod-bootstrap/v2/bootstrap/handlers"

"github.com/edgexfoundry/app-functions-sdk-go/v2/internal"
"github.com/edgexfoundry/app-functions-sdk-go/v2/internal/bootstrap/container"
sdkCommon "github.com/edgexfoundry/app-functions-sdk-go/v2/internal/common"
Expand Down Expand Up @@ -83,6 +85,8 @@ func (webserver *WebServer) ConfigureStandardRoutes() {
router.HandleFunc(common.ApiConfigRoute, controller.Config).Methods(http.MethodGet)
router.HandleFunc(internal.ApiAddSecretRoute, controller.AddSecret).Methods(http.MethodPost)

router.Use(handlers.ProcessCORS(webserver.config.Service.CORSConfiguration))

/// Trigger is not considered a standard route. Trigger route (when configured) is setup by the HTTP Trigger
// in internal/trigger/http/rest.go
}
Expand Down

0 comments on commit 2f5b3cf

Please sign in to comment.