Package play.server

Class Server.Builder

java.lang.Object
play.server.Server.Builder
Enclosing class:
Server

public static class Server.Builder extends Object
Configures and builds an embedded server. If not further configured, it will default to serving TEST mode over HTTP on a random available port.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • http

      public Server.Builder http(int port)
      Instruct the server to serve HTTP on a particular port.

      Passing 0 will make it serve on a random available port.

      Parameters:
      port - the port on which to serve http traffic
      Returns:
      the builder with port set.
    • https

      public Server.Builder https(int port)
      Configure the server to serve HTTPS on a particular port.

      Passing 0 will make it serve on a random available port.

      Parameters:
      port - the port on which to serve ssl traffic
      Returns:
      the builder with port set.
    • mode

      public Server.Builder mode(Mode mode)
      Set the mode the server should be run on (defaults to TEST)
      Parameters:
      mode - the Play mode (dev, prod, test)
      Returns:
      the builder with Server.Config set to mode.
    • build

      public Server build(Router router)
      Build the server and begin serving the provided routes as configured.
      Parameters:
      router - the router to use.
      Returns:
      the actively running server.
    • build

      public Server build(Function<BuiltInComponents,Router> block)
      Build the server and begin serving the provided routes as configured.
      Parameters:
      block - the router to use.
      Returns:
      the actively running server.