org.mashupbots.socko.webserver

WebServerConfig

case class WebServerConfig(serverName: String = "WebServer", hostname: String = "localhost", port: Int = 8888, idleConnectionTimeout: Duration = ..., webLog: Option[WebLogConfig] = scala.None, ssl: Option[SslConfig] = scala.None, http: HttpConfig = ..., tcp: TcpConfig = ...) extends Extension with Product with Serializable

Web server configuration

The configuration can be optionally loaded from Akka's application.conf file.

The following example configuration file:

akka-config-example {
server-name=AkkaConfigExample
hostname=localhost
port=9000
idle-connection-timeout=0

# Optional web log. If not supplied, web server activity logging is turned off.
web-log {

  # Optional path of actor to which web log events will be sent for writing. If not specified, the default
  # web log writer will be created
  custom-actor-path = "akka://my-system/user/web-log-writer"

  # Optional web log format for the default web log writer: Common, Combined or Extended.
  # If no specified, Common is the default.
  format = Common
}

# Optional SSL. If not supplied, ssl is turned off.
ssl {

  # Path to key store (server cert.)
  key-store-file=/tmp/ks.dat

  # Password to key store
  key-store-password=kspwd

  # Optional path to trust store (client cert.)
  trust-store-file=/tmp/ts.dat

  # Optional password to trust store
  trust-store-password=tspwd
}

# Optional HTTP protocol configuration. If not supplied, defaults are used.
http {

  # Maximum size of HTTP request. Defaults to 4MB.
  max-length-in-mb=4

  # Maximum length of the HTTP initial line. Defaults to 4096 bytes (4K).
  max-initial-line-length=4096

  # Maximum size of HTTP headers. Defaults to 8192 bytes (8K).
  max-header-size-in-bytes=8192

  # Maximum size of HTTP chunks. Defaults to 8192 bytes (8K).
  max-chunk-size-in-bytes=8192

  # Flag to indicate if HTTP chunk requests should be aggregated and presented
  # as a single HTTP request. Defaults to true.
  aggregate-chunks=true

  # Content under this size is not compressed. Defaults to 1024 bytes (1K).
  # Set to -1 to turn off compression; or 0 to compress all content.
  min-compressible-content-size-in-bytes=1024

  # Content over this size is not compressed. Defaults to 1MB
  max-compressible-content-size-in-bytes=60

  # Only content with the specified MIME type will be compressed
  compressible-content-types=[
    "text/plain", "text/html", "text/xml", "text/css",
    "application/xml", "application/xhtml+xml", "application/rss+xml",
    "application/json", "application/jsonml+json",
    "application/javascript", "application/x-javascript"]

  # Enable SPDY protocol or not. Defaults to `false`. If `true`, you must also enable SSL.
  spdy=false
}

# Optional TCP protocol configuration. If not supplied, defaults are used.
tcp {

  # Disable Nagle's algorithm. Defaults to `true` if not supplied.
  no-delay=

  # Set a hint the size of the underlying buffers for outgoing network I/O.
  send-buffer-size=

  # Get the size of the buffer actually used by the platform when receiving in data on this socket
  receive-buffer-size=

  # Turn on socket keep-alive. `true` or `false`.
  keep-alive=

  # Enable reuse address for a socket and not throw an "already bind exception". `true` or `false`.
  reuse-address=

  # Specify a linger-on-close timeout.
  so-linger=

  # Sets the type-of-service or traffic class field in the IP header for a TCP or UDP socket.
  traffic-class=

  # The number of requests that can be queued.
  accept-backlog=
}
}

can be loaded as follows:

object MyWebServerConfig extends ExtensionId[WebServerConfig] with ExtensionIdProvider {
  override def lookup = MyWebServerConfig
  override def createExtension(system: ExtendedActorSystem) =
    new WebServerConfig(system.settings.config, "akka-config-example")
}

val myWebServerConfig = MyWebServerConfig(actorSystem)
val webServer = new WebServer(myWebServerConfig, routes)
webServer.start()
serverName

Human friendly name of this server. Defaults to WebServer.

hostname

Hostname or IP address to bind. 0.0.0.0 will bind to all addresses. You can also specify comma separated hostnames/ip address like localhost,192.168.1.1. Defaults to localhost.

port

IP port number to bind to. Defaults to 8888.

idleConnectionTimeout

If a connection is idle for this duration, it will be closed. The default is 0, which indicates NO timeout and idle connections will NOT be closed.

webLog

Optional web log configuration. If None, web log events will NOT be generated.

ssl

SSL protocol configuration. If None, then SSL will not be turned on. Defaults to None.

http

HTTP protocol configuration. Defaults to an instance of org.mashupbots.socko.webserver.HttpConfig with default settings.

tcp

TCP IP protocol configuration. Defaults to an instance of org.mashupbots.socko.webserver.TcpConfig with default settings.

Linear Supertypes
Serializable, Serializable, Product, Equals, Extension, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. WebServerConfig
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. Extension
  7. AnyRef
  8. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new WebServerConfig(config: Config, prefix: String)

    Read configuration from AKKA's application.conf

  2. new WebServerConfig(serverName: String = "WebServer", hostname: String = "localhost", port: Int = 8888, idleConnectionTimeout: Duration = ..., webLog: Option[WebLogConfig] = scala.None, ssl: Option[SslConfig] = scala.None, http: HttpConfig = ..., tcp: TcpConfig = ...)

    serverName

    Human friendly name of this server. Defaults to WebServer.

    hostname

    Hostname or IP address to bind. 0.0.0.0 will bind to all addresses. You can also specify comma separated hostnames/ip address like localhost,192.168.1.1. Defaults to localhost.

    port

    IP port number to bind to. Defaults to 8888.

    idleConnectionTimeout

    If a connection is idle for this duration, it will be closed. The default is 0, which indicates NO timeout and idle connections will NOT be closed.

    webLog

    Optional web log configuration. If None, web log events will NOT be generated.

    ssl

    SSL protocol configuration. If None, then SSL will not be turned on. Defaults to None.

    http

    HTTP protocol configuration. Defaults to an instance of org.mashupbots.socko.webserver.HttpConfig with default settings.

    tcp

    TCP IP protocol configuration. Defaults to an instance of org.mashupbots.socko.webserver.TcpConfig with default settings.

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  11. val hostname: String

    Hostname or IP address to bind.

    Hostname or IP address to bind. 0.0.0.0 will bind to all addresses. You can also specify comma separated hostnames/ip address like localhost,192.168.1.1. Defaults to localhost.

  12. val http: HttpConfig

    HTTP protocol configuration.

    HTTP protocol configuration. Defaults to an instance of org.mashupbots.socko.webserver.HttpConfig with default settings.

  13. val idleConnectionTimeout: Duration

    If a connection is idle for this duration, it will be closed.

    If a connection is idle for this duration, it will be closed. The default is 0, which indicates NO timeout and idle connections will NOT be closed.

  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  18. val port: Int

    IP port number to bind to.

    IP port number to bind to. Defaults to 8888.

  19. val serverName: String

    Human friendly name of this server.

    Human friendly name of this server. Defaults to WebServer.

  20. val ssl: Option[SslConfig]

    SSL protocol configuration.

    SSL protocol configuration. If None, then SSL will not be turned on. Defaults to None.

  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  22. val tcp: TcpConfig

    TCP IP protocol configuration.

    TCP IP protocol configuration. Defaults to an instance of org.mashupbots.socko.webserver.TcpConfig with default settings.

  23. def validate(): Unit

    Validate current configuration settings.

    Validate current configuration settings. Throws an exception if configuration has errors.

  24. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. val webLog: Option[WebLogConfig]

    Optional web log configuration.

    Optional web log configuration. If None, web log events will NOT be generated.

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from Extension

Inherited from AnyRef

Inherited from Any

Ungrouped