Skip to content

Commit

Permalink
cmd/server: update github.com/moov-io/base to v0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Aug 19, 2019
1 parent d77d2f8 commit 90c0fb2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 36 deletions.
68 changes: 35 additions & 33 deletions cmd/server/files.go
Expand Up @@ -61,13 +61,12 @@ func getFiles(logger log.Logger, repo ICLFileRepository) http.HandlerFunc {

files, err := repo.getFiles() // TODO(adam): implement soft and hard limits
if err != nil {
logger.Log("files", fmt.Sprintf("error getting ICL files: %v", err), "requestId", moovhttp.GetRequestId(r))
logger.Log("files", fmt.Sprintf("error getting ICL files: %v", err), "requestID", moovhttp.GetRequestID(r))
moovhttp.Problem(w, err)
return
}
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("found %d files", len(files)), "requestId", requestId)
}
requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("found %d files", len(files)), "requestID", requestID)

w.Header().Set("X-Total-Count", fmt.Sprintf("%d", len(files)))
w.Header().Set("Content-Type", "application/json; charset=utf-8")
Expand All @@ -89,13 +88,12 @@ func createFile(logger log.Logger, repo ICLFileRepository) http.HandlerFunc {
req.ID = base.ID()
}
if err := repo.saveFile(&req); err != nil {
logger.Log("files", fmt.Sprintf("problem saving file %s: %v", req.ID, err), "requestId", moovhttp.GetRequestId(r))
logger.Log("files", fmt.Sprintf("problem saving file %s: %v", req.ID, err), "requestID", moovhttp.GetRequestID(r))
moovhttp.Problem(w, err)
return
}
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("creatd file=%s", req.ID), "requestId", requestId)
}
requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("creatd file=%s", req.ID), "requestID", requestID)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusCreated)
Expand All @@ -113,13 +111,14 @@ func getFile(logger log.Logger, repo ICLFileRepository) http.HandlerFunc {
}
file, err := repo.getFile(fileId)
if err != nil {
logger.Log("files", fmt.Sprintf("problem reading file=%s: %v", fileId, err), "requestId", moovhttp.GetRequestId(r))
logger.Log("files", fmt.Sprintf("problem reading file=%s: %v", fileId, err), "requestID", moovhttp.GetRequestID(r))
moovhttp.Problem(w, err)
return
}
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("rendering file=%s", fileId), "requestId", requestId)
}

requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("rendering file=%s", fileId), "requestID", requestID)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(file)
Expand Down Expand Up @@ -150,9 +149,8 @@ func updateFileHeader(logger log.Logger, repo ICLFileRepository) http.HandlerFun
moovhttp.Problem(w, err)
return
}
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("updating FileHeader for file=%s", fileId), "requestId", requestId)
}
requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("updating FileHeader for file=%s", fileId), "requestID", requestID)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusCreated)
Expand All @@ -172,9 +170,10 @@ func deleteFile(logger log.Logger, repo ICLFileRepository) http.HandlerFunc {
moovhttp.Problem(w, err)
return
}
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("deleted file=%s", fileId), "requestId", requestId)
}

requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("deleted file=%s", fileId), "requestID", requestID)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(`{"error": null}`)
Expand All @@ -194,9 +193,10 @@ func getFileContents(logger log.Logger, repo ICLFileRepository) http.HandlerFunc
moovhttp.Problem(w, err)
return
}
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("rendering file=%s contents", fileId), "requestId", requestId)
}

requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("rendering file=%s contents", fileId), "requestID", requestID)

w.Header().Set("Content-Type", "text/plain")
if err := imagecashletter.NewWriter(w).Write(file); err != nil {
logger.Log("files", fmt.Sprintf("problem rendering file=%s contents: %v", fileId, err))
Expand All @@ -221,15 +221,15 @@ func validateFile(logger log.Logger, repo ICLFileRepository) http.HandlerFunc {
return
}
if err := file.Create(); err != nil { // Create calls Validate
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("file=%s was invalid: %v", fileId, err), "requestId", requestId)
}
requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("file=%s was invalid: %v", fileId, err), "requestID", requestID)
moovhttp.Problem(w, err)
return
}
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("validated file=%s", fileId), "requestId", requestId)
}

requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("validated file=%s", fileId), "requestID", requestID)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(`{"error": null}`)
Expand Down Expand Up @@ -260,9 +260,10 @@ func addCashLetterToFile(logger log.Logger, repo ICLFileRepository) http.Handler
moovhttp.Problem(w, err)
return
}
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("added CashLetter=%s to file=%s", req.ID, fileId), "requestId", requestId)
}

requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("added CashLetter=%s to file=%s", req.ID, fileId), "requestID", requestID)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(file)
Expand Down Expand Up @@ -293,9 +294,10 @@ func removeCashLetterFromFile(logger log.Logger, repo ICLFileRepository) http.Ha
moovhttp.Problem(w, err)
return
}
if requestId := moovhttp.GetRequestId(r); requestId != "" {
logger.Log("files", fmt.Sprintf("removed CashLetter=%s to file=%s", cashLetterId, fileId), "requestId", requestId)
}

requestID := moovhttp.GetRequestID(r)
logger.Log("files", fmt.Sprintf("removed CashLetter=%s to file=%s", cashLetterId, fileId), "requestID", requestID)

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(`{"error": null}`)
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Expand Up @@ -6,11 +6,12 @@ require (
github.com/VividCortex/gohistogram v1.0.0 // indirect
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6
github.com/go-kit/kit v0.9.0
github.com/go-stack/stack v1.8.0 // indirect
github.com/gorilla/mux v1.7.3
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/moov-io/base v0.10.0-rc1.0.20190617172406-c11cd2f9d7fd
github.com/moov-io/base v0.10.0
github.com/prometheus/client_golang v1.1.0
github.com/rickar/cal v1.0.1 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
Expand Down
5 changes: 3 additions & 2 deletions go.sum
Expand Up @@ -46,8 +46,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/moov-io/base v0.10.0-rc1.0.20190617172406-c11cd2f9d7fd h1:cffJM28kEgNc7Tnb6Uyzei6NFNl9tT6oX19cGp0469I=
github.com/moov-io/base v0.10.0-rc1.0.20190617172406-c11cd2f9d7fd/go.mod h1:pPu/TAc9PkaaegbREVEeDHsGqyAlvji9vqTuARuAnd0=
github.com/moov-io/base v0.10.0 h1:9A/N0E+oB5nqxTMWszN06Az1PRAkW9EgQ4UQ/94S1IU=
github.com/moov-io/base v0.10.0/go.mod h1:pPu/TAc9PkaaegbREVEeDHsGqyAlvji9vqTuARuAnd0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -91,6 +91,7 @@ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5 h1:mzjBh+S5frKOsOBobWIMAbXavqjmgO17k/2puhcFR94=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3 h1:4y9KwBHBgBNwDbtu44R5o1fdOCQUEXhbk/P4A9WmJq0=
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
Expand Down

0 comments on commit 90c0fb2

Please sign in to comment.