Skip to content

Commit

Permalink
Rename mimetypes -> cmd-by-mimetype
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Apr 25, 2024
1 parent 1d7e436 commit a2d6b37
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type Config struct {
ArgHeader string `yaml:"arg-header"`
ForwardAuth bool `yaml:"forward-auth"`
AllowedMimeTypes []string `yaml:"allowed-mimetypes"`
Mimetypes map[string]Cmd `yaml:"mimetypes"`
CmdByMimeType map[string]Cmd `yaml:"cmd-by-mimetype"`
}

var (
Expand Down Expand Up @@ -219,10 +219,10 @@ func buildExecCommand(mimetype, addtlArgs string, c *Config) (*exec.Cmd, error)
var exists bool
slog.Info("Allowed formats", "formats", c.AllowedMimeTypes)
if isAllowedMIMEType(mimetype, c.AllowedMimeTypes) {
cmdConfig, exists = c.Mimetypes[mimetype]
cmdConfig, exists = c.CmdByMimeType[mimetype]
if !exists || (len(cmdConfig.Command) == 0) {
// Fallback to default if specific MIME type not configured or if command is empty
cmdConfig = c.Mimetypes["default"]
cmdConfig = c.CmdByMimeType["default"]
}
} else {
return nil, fmt.Errorf("undefined mimetype: %s", mimetype)
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ forward-auth: false
allowed-mimetypes: [
"text/plain"
]
mimetypes:
cmd-by-mimetype:
default:
cmd: "cat"
`)
Expand Down Expand Up @@ -142,7 +142,7 @@ forward-auth: false
allowed-mimetypes: [
"text/plain"
]
mimetypes:
cmd-by-mimetype:
default:
cmd: "cat"
`, method))
Expand Down
2 changes: 1 addition & 1 deletion scyllaridae.complex-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ allowed-mimetypes: [
"application/pdf",
"image/*"
]
mimetypes:
cmd-by-mimetype:
application/pdf:
cmd: "pdftotext"
args:
Expand Down
2 changes: 1 addition & 1 deletion scyllaridae.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ forward-auth: false
allowed-mimetypes: [
"text/plain"
]
mimetypes:
cmd-by-mimetype:
default:
cmd: "cat"

0 comments on commit a2d6b37

Please sign in to comment.