From a2d6b37d20140399bc4590adfa86f13b080015da Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Thu, 25 Apr 2024 12:25:07 -0400 Subject: [PATCH] Rename mimetypes -> cmd-by-mimetype --- main.go | 6 +++--- main_test.go | 4 ++-- scyllaridae.complex-example.yml | 2 +- scyllaridae.example.yml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 69a655e..e21f49d 100644 --- a/main.go +++ b/main.go @@ -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 ( @@ -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) diff --git a/main_test.go b/main_test.go index 4898f6e..f1dca98 100644 --- a/main_test.go +++ b/main_test.go @@ -50,7 +50,7 @@ forward-auth: false allowed-mimetypes: [ "text/plain" ] -mimetypes: +cmd-by-mimetype: default: cmd: "cat" `) @@ -142,7 +142,7 @@ forward-auth: false allowed-mimetypes: [ "text/plain" ] -mimetypes: +cmd-by-mimetype: default: cmd: "cat" `, method)) diff --git a/scyllaridae.complex-example.yml b/scyllaridae.complex-example.yml index 206059f..fbe0e76 100644 --- a/scyllaridae.complex-example.yml +++ b/scyllaridae.complex-example.yml @@ -7,7 +7,7 @@ allowed-mimetypes: [ "application/pdf", "image/*" ] -mimetypes: +cmd-by-mimetype: application/pdf: cmd: "pdftotext" args: diff --git a/scyllaridae.example.yml b/scyllaridae.example.yml index 006e351..34e13a7 100644 --- a/scyllaridae.example.yml +++ b/scyllaridae.example.yml @@ -12,6 +12,6 @@ forward-auth: false allowed-mimetypes: [ "text/plain" ] -mimetypes: +cmd-by-mimetype: default: cmd: "cat"