The request-response life cycle
The Play Framework uses Netty by default, so requests are received by NettyServer.
Netty allows a variety of actions including custom coding through handlers. We can define a handler that transforms a request into a desired response and provides it to Netty when bootstrapping the application. To integrate a Play app with Netty, PlayDefaultUpstreamHandler
is used.
Note
For additional information on requests used in Netty, refer to Netty docs at http://netty.io/wiki/user-guide-for-4.x.html and Netty ChannelPipeline docs at http://netty.io/4.0/api/io/netty/channel/ChannelPipeline.html.
PlayDefaultUpstreamHandler
extends org.jboss.netty.channel.SimpleChannelUpstreamHandler
to handle both HTTP and WebSocket requests. It is used when bootstrapping the application to Netty in the following way:
val defaultUpStreamHandler = new PlayDefaultUpstreamHandler(this, allChannels)
The messageReceived
method of SimpleChannelUpStreamHandler
is responsible for acting on the received...