Skip to content

Commit

Permalink
Merge a5e46c4 into ef2ee8a
Browse files Browse the repository at this point in the history
  • Loading branch information
mfdeveloper508 authored Sep 20, 2023
2 parents ef2ee8a + a5e46c4 commit e0380bc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
21 changes: 18 additions & 3 deletions cmd/server/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ func deleteFile(logger log.Logger, repo ICLFileRepository) http.HandlerFunc {

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(`{"error": null}`)

type response struct {
Error error `json:"error"`
}

json.NewEncoder(w).Encode(&response{Error: nil})
}
}

Expand Down Expand Up @@ -369,7 +374,12 @@ func validateFile(logger log.Logger, repo ICLFileRepository) http.HandlerFunc {

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(`{"error": null}`)

type response struct {
Error error `json:"error"`
}

json.NewEncoder(w).Encode(&response{Error: nil})
}
}

Expand Down Expand Up @@ -474,6 +484,11 @@ func removeCashLetterFromFile(logger log.Logger, repo ICLFileRepository) http.Ha

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(`{"error": null}`)

type response struct {
Error error `json:"error"`
}

json.NewEncoder(w).Encode(&response{Error: nil})
}
}
2 changes: 1 addition & 1 deletion cmd/server/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func TestFiles_validateFile(t *testing.T) {
w.Flush()

require.Equal(t, http.StatusOK, w.Code, w.Body)
assert.Contains(t, w.Body.String(), `"{\"error\": null}"`)
assert.Contains(t, w.Body.String(), `{"error":null}`)
})

t.Run("invalid file", func(t *testing.T) {
Expand Down
5 changes: 1 addition & 4 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ func Passthrough(lineIn string) (lineOut string) {

// DecodeEBCDIC will decode a line from EBCDIC-0037 to UTF-8
func DecodeEBCDIC(lineIn string) (lineOut string) {
lineOut, err := encoding.EBCDIC.NewDecoder().String(lineIn)
if err != nil {
fmt.Printf("Error decoding '%X' as EBCDIC: %v\n", lineIn, err)
}
lineOut, _ = encoding.EBCDIC.NewDecoder().String(lineIn)
return lineOut
}

Expand Down

0 comments on commit e0380bc

Please sign in to comment.