ebook img

Play Framework Essentials PDF

291 Pages·2014·1.694 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Play Framework Essentials

Play Framework Essentials Table of Contents Play Framework Essentials Credits About the Author About the Reviewers www.PacktPub.com Support files, eBooks, discount offers, and more Why subscribe? Free access for Packt account holders Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions 1. Building a Web Service Play – a framework used to write web applications Bootstrapping a Play application Play applications’ layout URL routing Route path parameters Parameters type coercion Parameters with fixed values Query string parameters Default values of query string parameters Trying the routes Building HTTP responses Serializing application data in JSON Reading JSON requests Validating JSON data Handling optional values and recursive types Summary 2. Persisting Data and Testing Testing your web service Writing and running tests Testing the HTTP layer Using the reverse router to generate URLs Running a fake Play application Effectively writing HTTP tests Persisting data Using a relational database Getting a reference to the currently running application Using a database management library Using Slick in Scala Using JPA in Java Integrating with other persistence technologies Populating the database with fixtures The application’s Global object Managing database schema evolutions Using an in-memory database for tests Summary 3. Turning a Web Service into a Web Application Delta between a web service and a web application Using the template engine to build web pages Inserting dynamic values Looping and branching Reusing document fragments Comments Import statements Generating HTML forms Repeated and nested fields Reading and validating HTML form data Handling the HTML form submission Validating the HTML form data The Scala form validation API The Java form validation API Optional and mandatory fields Sharing JSON validation and HTML form validation rules Handling content negotiation Putting things together Writing web user interface tests Summary 4. Integrating with Client-side Technologies Philosophy of Play regarding client-side technologies Serving static assets Sprinkling some JavaScript and CSS Using the JavaScript reverse router Managing assets from the build system Producing web assets Pipelining web assets’ transformations Concatenating and minifying JavaScript files Gzipping assets Fingerprinting assets Managing JavaScript dependencies Running JavaScript tests Summary 5. Reactively Handling Long-running Requests Play application’s execution model Scaling up your server Embracing non-blocking APIs Managing execution contexts Writing incremental computations using iteratees Streaming results using enumerators Manipulating data streams by combining iteratees, enumerators, and enumeratees Unidirectional streaming with server-sent events Preparing the ground Transforming streams of data using enumeratees Implementing a publish/subscribe system using Akka Bidirectional streaming with WebSockets Controlling the data flow Summary 6. Leveraging the Play Stack – Security, Internationalization, Cache, and the HTTP Client Handling security concerns Authentication Cross-site scripting Cross-site request forgery HTTP request filters Using the CSRF filter Enabling HTTPS Saving computation time using cache Serving content in several languages Calling remote web services Background – the OAuth 2.0 protocol Integrating your application with your preferred social network Implementing the OAuth client Calling the HTTP API of your preferred social network Summary 7. Scaling Your Codebase and Deploying Your Application Making an action’s logic reusable and composable with action builders Capturing the logic of actions that use blocking APIs Capturing the logic of actions that require authentication Combining action builders Modularizing your code Applying the inversion of control principle Using dynamic calls in route definitions Setting up a dependency injection system Making your code injectable Mocking components Splitting your code into several artifacts Splitting your controller layer into several artifacts Application deployment Deploying to your dedicated infrastructure Deploying to the cloud Handling per environment configuration Overriding configuration settings using Java system properties Using different configuration files Summary Index Play Framework Essentials

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.