Skip to content

Commit

Permalink
Merge pull request #87 from anonychun/master
Browse files Browse the repository at this point in the history
Fix invalid memory address or nil pointer dereference
  • Loading branch information
olttwa authored Nov 10, 2020
2 parents 163ecb0 + b5f2838 commit ab776e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
12 changes: 8 additions & 4 deletions proctord/server/api.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
package server

import (
"proctor/proctord/instrumentation"
"time"

"proctor/proctord/config"
"proctor/proctord/instrumentation"
"proctor/proctord/logger"
"proctor/proctord/redis"
"proctor/proctord/storage/postgres"
"time"

"github.com/tylerb/graceful"
"github.com/urfave/negroni"
)

func Start() error {
redisClient := redis.NewClient()
postgresClient := postgres.NewClient()

err := instrumentation.InitNewRelic()
if err != nil {
logger.Fatal(err)
}
appPort := ":" + config.AppPort()

server := negroni.New(negroni.NewRecovery())
router, err := NewRouter()
router, err := NewRouter(postgresClient, redisClient)
if err != nil {
return err
}
Expand Down
14 changes: 4 additions & 10 deletions proctord/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package server

import (
"fmt"
"net/http"
"path"
"proctor/proctord/audit"
"proctor/proctord/config"
"proctor/proctord/docs"
http_client "proctor/proctord/http"
"proctor/proctord/instrumentation"
"proctor/proctord/jobs/execution"
"proctor/proctord/jobs/logs"
"proctor/proctord/jobs/metadata"
Expand All @@ -16,21 +19,13 @@ import (
"proctor/proctord/redis"
"proctor/proctord/storage"
"proctor/proctord/storage/postgres"
"net/http"
"path"

"proctor/proctord/instrumentation"
"github.com/gorilla/mux"
)

var postgresClient postgres.Client

func NewRouter() (*mux.Router, error) {
func NewRouter(postgresClient postgres.Client, redisClient redis.Client) (*mux.Router, error) {
router := mux.NewRouter()

redisClient := redis.NewClient()
postgresClient = postgres.NewClient()

store := storage.New(postgresClient)
metadataStore := metadata.NewStore(redisClient)
secretsStore := secrets.NewStore(redisClient)
Expand All @@ -55,7 +50,6 @@ func NewRouter() (*mux.Router, error) {
fmt.Fprintf(w, "pong")
})


router.HandleFunc("/docs", docs.APIDocHandler)
router.PathPrefix("/docs/").Handler(http.StripPrefix("/docs/", http.FileServer(http.Dir(config.DocsPath()))))
router.HandleFunc("/swagger.yml", func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit ab776e3

Please sign in to comment.