30
October 2013 Building Web Apps in Ratpack Daniel Woods

Building Web Apps in Ratpack

Embed Size (px)

DESCRIPTION

see description

Citation preview

Page 1: Building Web Apps in Ratpack

October 2013

Building Web Apps in Ratpack

Daniel Woods

Page 2: Building Web Apps in Ratpack

About Me

@danveloper /danveloper

#editordaniel.p.woods

Page 3: Building Web Apps in Ratpack

Welcome to Ratpack• Inspired by Ruby’s Sinatra Framework

• Built on Netty

• Written in Java, Optimized for Groovy• Also, Java 7 & Java 8

• Totally unopinionated framework

• Optional Google Guice integration

• Optional Gradle integration

• Rapid development with SpringLoaded

Page 4: Building Web Apps in Ratpack

When to use Ratpack?• Micro-services

• Supporting Single-Page Applications

• High-throughput apps

• Lightweight apps• No Container!

• Cloud Deployments• Simple packaging strategy

• Mock Services in Test?

Page 5: Building Web Apps in Ratpack

Quick Intro to Ratpack• Runnable from a Groovy script!

Page 6: Building Web Apps in Ratpack

Quick Intro to Ratpack• Simple Groovy DSL for Handler chain

Page 7: Building Web Apps in Ratpack

Quick Intro to Ratpack• Support for prefixed endpoints

Page 8: Building Web Apps in Ratpack

Quick Intro to Ratpack• Handling content-type

Page 9: Building Web Apps in Ratpack

More Complex Needs…• Gradle

Page 10: Building Web Apps in Ratpack

More Complex Needs…• Dependency Injection

Page 11: Building Web Apps in Ratpack

More Complex Needs…• Modules

Page 12: Building Web Apps in Ratpack

Getting all Dynamic…• Templates

Page 13: Building Web Apps in Ratpack

Getting all Dynamic…• Templates

Page 14: Building Web Apps in Ratpack

Getting all Dynamic…• Handlebars Template Support!

Page 15: Building Web Apps in Ratpack

Accessing Parameters• request.queryParams

Page 16: Building Web Apps in Ratpack

Accessing Parameters• context.pathTokens

Page 17: Building Web Apps in Ratpack

Modularizing Handlers• MongoDBAssetHandler example

Page 18: Building Web Apps in Ratpack

Building Ratpack• gradle installApp

Page 19: Building Web Apps in Ratpack

Packaging Ratpack• gradle distZip

Page 20: Building Web Apps in Ratpack

Deploying Ratpack• Heroku

• Step 0 – Add the Gradle Wrapper to your Project

Page 21: Building Web Apps in Ratpack

Deploying Ratpack• Heroku

• Step 0.1 – Add a settings.gradle file to your Project• Setting the rootProject.name = ‘demo’ will allow the

buildpack to work properly.

Page 22: Building Web Apps in Ratpack

Deploying Ratpack• Heroku

• Step 1 – Authenticate on Terminal

Page 23: Building Web Apps in Ratpack

Deploying Ratpack• Heroku

• Step 2 – Create your app with Heroku

Page 24: Building Web Apps in Ratpack

Deploying Ratpack• Heroku

• Step 3 – Configure the buildpack

Page 25: Building Web Apps in Ratpack

Deploying Ratpack• Heroku

• Step 4.0 – git init (if you haven’t already)• Step 4.1 – add Heroku app’s remote git endpoint• Step 4.2 – git push -u heroku master

Page 26: Building Web Apps in Ratpack

Deploying Ratpack• Heroku

• Step 5 – Visit App

Page 27: Building Web Apps in Ratpack

Deploying Ratpack• Heroku

• Step 5 – Visit App

Page 28: Building Web Apps in Ratpack

Testing Ratpack Apps

Jeff Beck@beckje01

Page 29: Building Web Apps in Ratpack

Ratpack Resources• The Ratpack Manual

• http://www.ratpack-framework.org/manual/current/

• Ratpack GitHub (Samples, etc)• https://github.com/ratpack

• Continuous Integration• http://drone.io• ??? (tweet me!)

• Tomas Lin, Cloud Foundry deployment• http://fbflex.wordpress.com/2013/08/07/ratpack-to-cloudfoundry-with-java-buildpack/

Page 30: Building Web Apps in Ratpack

The End