Skip to content

Commit

Permalink
Merge pull request #62 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 2.1.2 - remove CORS middleware
  • Loading branch information
briskt authored Aug 28, 2023
2 parents 0bbfb3c + 7d6d49d commit a5d9b36
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
21 changes: 0 additions & 21 deletions server/cors_middleware.go

This file was deleted.

13 changes: 3 additions & 10 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import (
mfa "github.com/silinternational/serverless-mfa-api-go"
)

var (
envConfig mfa.EnvConfig
)
var envConfig mfa.EnvConfig

func main() {
log.SetOutput(os.Stdout)
Expand All @@ -31,7 +29,7 @@ func main() {
// ListenAndServe starts an HTTP server with a given address and
// handler defined in NewRouter.
log.Println("Starting service on port 8080")
router := newRouter([]mux.MiddlewareFunc{corsMiddleware})
router := newRouter()
log.Fatal(http.ListenAndServe(":8080", router))
}

Expand Down Expand Up @@ -88,15 +86,10 @@ var routes = []route{
}

// newRouter forms a new mux router, see https://github.com/gorilla/mux.
func newRouter(mws []mux.MiddlewareFunc) *mux.Router {
func newRouter() *mux.Router {
// Create a basic router.
router := mux.NewRouter().StrictSlash(true)

// attach any extra middleware
for _, mw := range mws {
router.Use(mw)
}

// authenticate request based on api key and secret in headers
// also adds user to context
router.Use(authenticationMiddleware)
Expand Down
8 changes: 3 additions & 5 deletions u2fserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
u2fsim "github.com/silinternational/serverless-mfa-api-go/u2fsimulator"
)

var (
envConfig mfa.EnvConfig
)
var envConfig mfa.EnvConfig

func main() {
log.SetOutput(os.Stdout)
Expand All @@ -23,7 +21,7 @@ func main() {
// ListenAndServe starts an HTTP server with a given address and
// handler defined in NewRouter.
log.Println("Starting service on port 8080")
router := newRouter(nil)
router := newRouter()
log.Fatal(http.ListenAndServe(":8080", router))
}

Expand All @@ -47,7 +45,7 @@ var routes = []route{
}

// newRouter forms a new mux router, see https://github.com/gorilla/mux.
func newRouter(mws []mux.MiddlewareFunc) *mux.Router {
func newRouter() *mux.Router {
// Create a basic router.
router := mux.NewRouter().StrictSlash(true)

Expand Down

0 comments on commit a5d9b36

Please sign in to comment.