Skip to content

Commit

Permalink
updating from master
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquechehad committed Feb 17, 2017
2 parents f5627cd + db9d0b4 commit ecf1ff9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"

"github.com/gorilla/mux"
"github.com/rs/cors"
// postgres driver for migrate
_ "github.com/mattes/migrate/driver/postgres"
"github.com/nuveo/prest/config"
Expand Down Expand Up @@ -49,7 +50,9 @@ func app() {
if cfg.JWTKey != "" {
n.Use(middlewares.JwtMiddleware(cfg.JWTKey))
}

r := config.GetRouter()

r.HandleFunc("/databases", controllers.GetDatabases).Methods("GET")
r.HandleFunc("/schemas", controllers.GetSchemas).Methods("GET")
r.HandleFunc("/tables", controllers.GetTables).Methods("GET")
Expand All @@ -67,6 +70,14 @@ func app() {
negroni.HandlerFunc(middlewares.AccessControl),
negroni.Wrap(crudRoutes),
))

if cfg.CORSAllowOrigin != nil {
c := cors.New(cors.Options{
AllowedOrigins: cfg.CORSAllowOrigin,
})
n.Use(c)
}

n.UseHandler(r)
n.Run(fmt.Sprintf(":%v", cfg.HTTPPort))
}

0 comments on commit ecf1ff9

Please sign in to comment.