Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Configuration

Aaron S. Hawley edited this page Nov 1, 2013 · 7 revisions

. . . Deprecation Note

This documentation is for release 0.9.0 (from 03/2012), which is built against Scala 2.9.1 and Akka 1.3.1 (see Requirements for more information). Most likely, this is not the place you want to look for information. Please turn to the main spray site at http://spray.io for more information about other available versions.

. . .

spray supports a number of configuration parameters that you can use to tweak sprays behavior. These config setting reside next to the akka section in your akka.conf file, in a section called spray. The Template Project comes with a very basic configuration that you can use as the basis for own.

Currently spray supports the following config settings:

  • "root-actor-id", a string containing the id of the RootService actor. You should rarely need to change this. The default is "spray-root-service"
  • "timeout-actor-id", a string containing the id of the actor handling Timeout messages. The default is "spray-root-service" (i.e. the RootService actor also handles timeouts).
  • "request-timeout", an integer value representing the number of milliseconds in which a request has to be responded before triggering an async timeout error response. The default is 1000.
  • "root-path", an optional string that, if set, is expected as a prefix of all requests URI paths received by the application and automatically removed before route processing. Useful for example in servlet containers where the spray application is deployed under a certain base URL. The default is "not set".
  • "compact-json-printing", a boolean value signifying whether spray should use the CompactPrinter rather than the PrettyPrinter when using SprayJsonSupport (also see the Marshalling and Unmarshalling chapter). The default is false.
  • "logging-target", either "AkkaEventHandler" or "SLF4J", specifies the destination of log messages generated by the cc.spray.utils.Logging trait. If set to "AkkaEventHandler" log messages are sent to the Akka EventHandler, which then handles them according to its configuration. If set to "SLF4J" the messages will be directly logged to SLF4J (which you need to provide an explicit dependency for, since spray does not do this).
  • "relaxed-header-parsing", a boolean indicating whether spray should be lenient with request headers that don't fully conform to the HTTP spec, i.e. log a warning but continue request processing. The default value is false, which causes spray to not accept invalid headers and reply with a 400 BadRequest response.
  • 'file-chunking-threshold-size', a Long defining the minimal file size in bytes triggering content streaming
  • 'file-chunking-chunk-size', an Int defining the size of an individual file-chunking chunk (in bytes)

You enable content streaming by setting 'file-chunking-threshold-size' to some value less than Long.MaxValue. The 'file-chunking-chunk-size' setting has a default value of 512 Kb.

Additionally the spray config section may contain a sub section called users which contains username / password combinations for the FromConfigUserPassAuthenticator as discussed in the Authentication/Authorization chapter.

Example:

spray {
    request-timeout = 1000
    users {
        alice = "banana"
        bob = "coconut"
    }
}