Skip to content

Commit

Permalink
Make binaryContentTypes global so it isn't building it every time.
Browse files Browse the repository at this point in the history
  • Loading branch information
tateexon committed Jun 25, 2024
1 parent ac2569a commit 8c2e34c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/server/http/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import (
"github.com/gorilla/handlers"
)

var binaryContentTypes = []string{
"application/octet-stream",
"image/",
"audio/",
"video/",
"application/pdf",
}

// RequestData struct to hold request data
type RequestData struct {
Method string `json:"method"`
Expand Down Expand Up @@ -169,14 +177,6 @@ func writeLog(writer io.Writer, params handlers.LogFormatterParams, body string)
// isBinaryContent checks to see if the body is a common binary content type
func isBinaryContent(r *http.Request) bool {
contentType := r.Header.Get("Content-Type")
binaryContentTypes := []string{
"application/octet-stream",
"image/",
"audio/",
"video/",
"application/pdf",
}

for _, binaryType := range binaryContentTypes {
if strings.HasPrefix(contentType, binaryType) {
return true
Expand Down

0 comments on commit 8c2e34c

Please sign in to comment.