Skip to content
This repository was archived by the owner on May 31, 2026. It is now read-only.

Server configuration

Derek Clarkson edited this page Oct 8, 2023 · 3 revisions

Voodoo has variety of configuration options. Some specific to the server and some related to endpoints.

Also see:

XCTest configuration

Configuration for the Swift XCTest API is handled through arguments on the VoodooServer class. The initialiser looks like this:

public init(portRange: ClosedRange<Int> = 8080 ... 8090,
                graphQLPath: String = "/graphql",
                useAnyAddr: Bool = false,
                templatePath: URL? = nil,
                templateExtension: String = "json",
                filePaths: [URL]? = nil,
                verbose: Bool = false,
                hummingbirdVerbose: Bool = false,
                @EndpointBuilder endpoints: () -> [Endpoint] = { [] }) throws {
    // ..
}

voodoo configuration

For the command line configuration is done through arguments to voodoo and through YAML files. The arguments to voodoo look like this:

$ .build/release/voodoo run --help

OVERVIEW: Configures and starts the server

This scans the port range (Default: 8080-8090) for the first free port. It then starts the server on that port. This allows for
parallel testing. The port range change be changed using the --port-range argument.

USAGE: voodoo run [--verbose] [--hummingbird-verbose] [--use-any-addr] [--port-range <port-range>] [--template-dir <template-dir>] --config <config> [--file-dir <file-dir> ...]

OPTIONS:
  --verbose
  --hummingbird-verbose   Activates trace mode in the Hummingbird server for tracking errors.
  --use-any-addr          By default the server uses 127.0.0.1 as it's IP address. However that will not work in containers suck
                          as Docker where 0.0.0.0 is need. Enabling this flag sets the server's IP to the any address (0.0.0.0).
                          However be aware that this may cause firewalls and other security software to flag the server.
  -p, --port-range <port-range>
                          The port range to start the server on. Must be either a single port or a valid range written as
                          "xxxx-yyyy" where xxxx is the lower bound of the range and yyyy is upper.
  -t, --template-dir <template-dir>
                          A directory path where response template files can be found. Templates are used to generate response
                          bodies. They can contain mustache template keys to insert data from the server. Reference here:
                          https://hummingbird-project.github.io/hummingbird/current/hummingbird-mustache/mustache-syntax.html
  -c, --config <config>   either a directory path containing YAML files or a reference to a particular file. If a directory is
                          referenced then all YAML files in the directory will be loaded. If a specific file is referenced then
                          the end points in that file and any files it references will be loaded. See the readme doco for
                          details on all the options that are available.
  -f, --file-dir <file-dir>
                          A directory path where non-template files are sourced from. Mostly locations of image files and other
                          static web like resources. If the server receives a request and does not have an end point configured
                          for it then it scans this directory to see if the request path maps to a stored file.
  --version               Show the version.
  -h, --help              Show help information.

Configuration options

VoodooServer initialiser argument Voodoo argument Default Description
N/A -c
--config
voodoo only, required.
The path to the directory or initial YAML file that defines the server configuration. If a directory path is passed then the directory (and sub-directories) will be scanned. All YAML files found will be read for endpoints to configure. If a single YAML file is passed then it is assumed that the file, and any files it links to, contain the entire configuration.
voodoo will not start without this argument being passed.
portRange -p
--port-range
8080...8090 Defines the port range that Voodoo will search to find a free port to start on. If no free port is found then an error will be thrown.
graphQLPath N/A /graphql The path that GraphQL requests are expected to arrive on.
useAnyAddr --use-any-addr false If set to true changes the servers IP address from the home address (127.0.0.1) to the "all" address (0.0.0.0). This is mostly for when running the server inside a container such as a docker container where the internal IP is not available to outside clients.
templatePath -t
--template-path
The path to a folder that contains mustache templates to use for generating responses. The templates are expected to have the extension specified by the template extension argument.
The paths of the files in the folder will be used as the template keys.
If a nil is passed to the Swift argument or the voodoo argument is not passed then no path will be set and no templates will be available.
filePaths -f ...
--file-path ...
In Swift you pass an array. On the command line you can pass multiple of these arguments.
Specifies one or more directory paths where files can be served from. If a request comes into the server which is not handled by a registered endpoint, then the path component of the request is checked against these directories. If it matches a file, then that file is returned as the response to the incoming request.
This is typically used to serve things like web content.
verbose --verbose false If true puts Voodoo into verbose mode which means it logs the endpoints it finds, incoming requests and other related data.
hummingbirdVerbose --hummingbird-verbose false If enabled, tells the internal hummingbird server to verbose log information.
endpoints N/A Swift API only.
A list of endpoints to configure the server with. Note that endpoints can also be added after the server is started. Also note that this is configured as a Swift Result Builder which means less boilerplate is needed to build the list of endpoints.

Clone this wiki locally