Scala Java HTML Shell JavaScript Groff
Latest commit 1fd78c9 Dec 6, 2016 @richdougherty richdougherty committed with gmethvin Move cookies into attributes; remove cookie global state (#6695)
The goal of this change is to remove global state from the cookies,
session and flash request properties. Before this change these properties were
defined as lazy values on the RequestHeader trait.

Unfortunately the lazy values needed to access global state to get
their configuration and it was difficult to feed into the
RequestHeader trait without adding configuration as a property of the
RequestHeader object itself.

This commit changes the RequestHeader trait so that it stores the
cookie, session and flash objects as attributes of the RequestHeader
in a TypedMap instead of as lazy properties.

The attributes are explicitly attached to the RequestHeader using a
new type of class called a RequestFactory. The RequestFactory is used
to create every RequestHeader that is sent to an application.

The RequestFactory participates in dependency injection, so it doesn't
use any global state to do its work. It manipulates the cookie,
session and flash objects based on its injected configuration.

In order to make it easier to create, transform and manipulate
requests I simplified their properties a bit more. I made two new
objects to bundle together sets of related request properties. The
RequestTarget class holds the URI, path and query string. The
RemoteConnection class holds the remote address, HTTPS and certificate
information.

I considered using a filter to attach the attributes to the request.
However a filter doesn't work with only a RequestHeader; it expects a
Request with a body. Also filters are asynchronous; a simple
synchronous function for creating RequestHeaders is usually more
convenient.

Since I was already moving the cookies, session and flash properties
into attributes, I did the same for the request id and request tags.

Things to consider in the future:

1. Moving the ForwardedHeaderHandler logic out of the ModelConversion
   classes and into the default RequestFactory.
2. Making the RequestFactory implementation configurable so that
   users can make their own kinds of requests.
3. Making aspects of the default RequestFactory implementation
   configurable, e.g. not attaching request ids if they're not
   needed.
4. Updating the Result object so that it has attributes, then
   storing the Result's cookie, session and flash objects as
   attributes.

README.md

Gitter Maven

Play Framework - The High Velocity Web Framework

The Play Framework combines productivity and performance making it easy to build scalable web applications with Java and Scala. Play is developer friendly with a "just hit refresh" workflow and built-in testing support. With Play, applications scale predictably due to a stateless and non-blocking architecture. By being RESTful by default, including assets compilers, JSON & WebSocket support, Play is a perfect fit for modern web & mobile applications.

Learn More

License

This software is licensed under the Apache 2 license, quoted below.

Copyright (C) 2009-2016 Lightbend Inc. (https://www.lightbend.com).

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.