Learning Ratpack

Book description

Build robust, highly scalable reactive web applications with Ratpack, the lightweight JVM framework. With this practical guide, you’ll discover how asynchronous applications differ from more traditional thread-per-request systems—and how you can reap the benefits of complex non-blocking through an API that makes the effort easy to understand and adopt.

Author Dan Woods—a member of the Ratpack core team—provides a progressively in-depth tour of Ratpack and its capabilities, from basic concepts to tools and strategies to help you construct fast, test-driven applications in a semantic and expressive way. Ideal for Java web developers familiar with Grails or Spring, this book is applicable to all versions of Ratpack 1.x.

  • Configure your applications and servers to accommodate the cloud
  • Use Ratpack testing structures on both new and legacy applications
  • Add advanced capabilities, such as component binding, with modules
  • Explore Ratpack’s static content generation and serving mechanisms
  • Provide a guaranteed execution order to asynchronous processing
  • Model data and the data access layer to build high-performance, data-driven applications
  • Work with reactive and functional programming strategies
  • Use distribution techniques that support continuous delivery and other deployment tactics

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. Who Is the Target Audience for This Book?
    2. What Is This Book Not Trying to Accomplish?
      1. No Breaking Changes!
    3. Staying in Touch
    4. Acknowledgments
  3. 1. Welcome to Ratpack
    1. Hello, World!
      1. Running the Example
      2. Rapid Prototyping
    2. Handler Chain
      1. URL Path Bindings
      2. Prefixed Routes
      3. Path Tokens
      4. Request Parameters
      5. Parsing Request Data
      6. Content Negotiation in Handlers
    3. Chapter Summary
  4. 2. Getting Started
    1. Library Structure
    2. Project Structure
    3. Ratpack Gradle Plugin
      1. Gradle Wrapper
      2. Hot Reloading
    4. Lazybones
    5. Building from a Main Class
    6. Working with Handlers
      1. Understanding the Chain API Interactions in Groovy and Java
      2. Standalone Handlers
    7. Chapter Summary
  5. 3. Testing Ratpack Applications
    1. Spock Test Structure
    2. Functional Testing
      1. Bootstrapping Test Data
      2. Architecting for Improved Testability
    3. Integration Testing
    4. Unit Testing
    5. Unit Testing Standalone Handlers
    6. Other Testing Scenarios
    7. Chapter Summary
  6. 4. Application Configuration
    1. Configuring with Environment Variables and System Properties
      1. Configuring with Environment Variables
      2. Configuration with System Properties
    2. Nested Configuration Models
    3. Custom Configuration Source
    4. Setting Server Configuration
    5. Chapter Summary
  7. 5. Ratpack Modules
    1. Extending Ratpack with Registries
    2. Google Guice
      1. BindingsSpec in Groovy
    3. Framework Modules
      1. Configurable Modules
    4. Modular Object Rendering in Ratpack
      1. Rendering with Content Type
      2. Rendering JSON Data
      3. Special Rendering Scenarios
    5. Chapter Summary
  8. 6. Serving Web Assets
    1. Serving Static Content
      1. Caveats to the FileHandler
      2. Using FileSystemBinding to Customize Asset Resolution
    2. Serving Dynamic Content
      1. Handlebars.js Support
      2. Thymeleaf Support
      3. Groovy Markup Templates
    3. Conditionally Serving Content
      1. Conditionally Scoping Resources
      2. Conditionally Serving Assets Based on Request Attributes
    4. Sending Files from Handlers
    5. Customizing 404 Behavior
    6. Cache Control
    7. Asset Pipeline
    8. Chapter Summary
  9. 7. Asynchronous Programming, Promises, and Executions
    1. Promises: A Better Approach to Async Programming
    2. Execution Model
    3. Scheduling Execution Segments for Computation or I/O
    4. Leveraging Executions on Unmanaged Threads
    5. Error Handling
      1. Execution-Wide Error Handling
      2. Promise Error Handling
    6. Creating Promises on Your Own
      1. Promises from Synchronous Calculations
      2. Promises from Asynchronous Calls
    7. Chapter Summary
  10. 8. Data-Driven Web Applications
    1. Groovy SQL Support
    2. Connection Pooling with HikariCP Support
    3. Ratpack and Grails GORM
    4. Designing Data-Driven Service APIs in Ratpack
    5. Chapter Summary
  11. 9. Ratpack and Spring Boot
    1. Adding Spring Boot to Your Ratpack Project
    2. Creating a Spring Boot–Backed Registry
    3. API Design with Ratpack and Spring
      1. Other Notes on API Design with Ratpack and Spring
    4. Known Limitations
    5. Chapter Summary
  12. 10. Reactive Programming in Ratpack
    1. Overview of Reactive Programming
    2. Promise as a Reactive Data Structure
      1. Transforming Data with Promises
      2. Filtering Data with Promises
      3. Composing Data with Promises
    3. Reactive Streams
      1. Publishers and bindExec
    4. RxJava
      1. Parallel Processing Using RxJava
      2. Further Reading on RxJava
    5. Chapter Summary
  13. 11. Sessions and Security
    1. Integrating Session Support
      1. Persisting Objects
      2. Configuring the SessionModule
    2. Client-Side Sessions
    3. Distributed Sessions
    4. Working with Cookies
      1. Tuning Cookies
      2. Expiring Cookies
    5. Chapter Summary
  14. 12. Application Security
    1. SSL Support
    2. Basic Authentication
      1. Custom UsernamePasswordAuthenticator
    3. Form-Based Authentication
      1. Data-Driven Form Authentication
    4. Additional Authentication Means
    5. Chapter Summary
  15. 13. Going to Production
    1. Publishing Metrics
      1. Enabling Reporting
      2. Publishing Custom Metrics
    2. Application Health Checks
    3. Building Distributions
    4. Production Checklist
    5. Chapter Summary
  16. Index

Product information

  • Title: Learning Ratpack
  • Author(s): Dan Woods
  • Release date: June 2016
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491921616