Skip to content

Commit

Permalink
More documentation and a tiny refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall authored Apr 27, 2024
1 parent 4d7da20 commit b9bd27b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Define the service's behavior in `scyllaridae.yml`.

You can specify which mimetypes the service can act on in `allowedMimeTypes`

And specify different commands for different mimetypes in `cmdByMimeType`, or set the default command to run for all mimetypes with the `default` key.
And specify different commands for different mimetypes in `cmdByMimeType`, or set the default command to run for all mimetypes with the `default` key. Here's another more [complex example YML](./scyllaridae.complex.yml).

```yaml
allowedMimeTypes:
Expand All @@ -21,8 +21,10 @@ cmdByMimeType:
args:
- "-X"
- "POST"
# read the source media file in from stdin
- "-F"
- "datafile=@-"
# send the media file to FITS which will return the XML to stdout
- "http://fits:8080/fits/examine"
```
Expand Down
4 changes: 1 addition & 3 deletions internal/config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,11 @@ func ReadConfig(yp string) (*ServerConfig, error) {
}

func BuildExecCommand(mimetype, addtlArgs string, c *ServerConfig) (*exec.Cmd, error) {
var cmdConfig Command
var exists bool
if !IsAllowedMimeType(mimetype, c.AllowedMimeTypes) {
return nil, fmt.Errorf("undefined mimetype: %s", mimetype)
}

cmdConfig, exists = c.CmdByMimeType[mimetype]
cmdConfig, exists := c.CmdByMimeType[mimetype]
if !exists {
cmdConfig = c.CmdByMimeType["default"]
}
Expand Down
4 changes: 4 additions & 0 deletions scyllaridae.complex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ cmdByMimeType:
cmd: convert
args:
- "pdf:-[0]"
# %s is a special string used by scyllaridae
# populated by the X-Islandora-Args HTTP header
- "%s"
- "pdf:-"
default:
cmd: convert
args:
- "-"
# %s is a special string used by scyllaridae
# populated by the X-Islandora-Args HTTP header
- "%s"
- "image:-"

0 comments on commit b9bd27b

Please sign in to comment.