Building Web Apps in Ratpack
Daniel Woods

October 2013
About Me
@danveloper

#editor

/danveloper

daniel.p.woods
Welcome to Ratpack
• Inspired by Ruby’s Sinatra Framework
• Built on Netty
• Written in Java, Optimized for Groovy
• Also,...
When to use Ratpack?
• Micro-services
• Supporting Single-Page Applications
• High-throughput apps

• Lightweight apps
• N...
Quick Intro to Ratpack
• Runnable from a Groovy script!
Quick Intro to Ratpack
• Simple Groovy DSL for Handler chain
Quick Intro to Ratpack
• Support for prefixed endpoints
Quick Intro to Ratpack
• Handling content-type
More Complex Needs…
• Gradle
More Complex Needs…
• Dependency Injection
More Complex Needs…
• Modules
Getting all Dynamic…
• Templates
Getting all Dynamic…
• Templates
Getting all Dynamic…
• Handlebars Template Support!
Accessing Parameters
• request.queryParams
Accessing Parameters
• context.pathTokens
Modularizing Handlers
• MongoDBAssetHandler example
Building Ratpack
• gradle installApp
Packaging Ratpack
• gradle distZip
Deploying Ratpack
• Heroku
• Step 0 – Add the Gradle Wrapper to your Project
Deploying Ratpack
• Heroku
• Step 0.1 – Add a settings.gradle file to your Project
• Setting the rootProject.name = ‘demo’...
Deploying Ratpack
• Heroku
• Step 1 – Authenticate on Terminal
Deploying Ratpack
• Heroku
• Step 2 – Create your app with Heroku
Deploying Ratpack
• Heroku
• Step 3 – Configure the buildpack
Deploying Ratpack
• Heroku
• Step 4.0 – git init (if you haven’t already)
• Step 4.1 – add Heroku app’s remote git endpoin...
Deploying Ratpack
• Heroku
• Step 5 – Visit App
Deploying Ratpack
• Heroku
• Step 5 – Visit App
Testing Ratpack Apps

Jeff Beck
@beckje01
Ratpack Resources
• The Ratpack Manual
• http://www.ratpack-framework.org/manual/current/
• Ratpack GitHub (Samples, etc)
...
The End
Upcoming SlideShare
Loading in...5
×

Building Web Apps in Ratpack

2,686

Published on

see description

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,686
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
29
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide
  • Micro-services: So-called “Thin Server Architecture” High-throughput: 22,000 messages per second (http://netty.io/testimonials)
  • demo1/demo1.groovyview headers: curl -I http://localhost:5050post: curl -X POST http://localhost:5050/apiview static: http://localhost:5050/dan.htmlview headers of static content: curl -I http://localhost:5050/dan.html
  • demo2/demo2.groovyput: curl -X PUT http://localhost:5050/apipost: curl -X PUT http://localhost:5050/api
  • demo3/demo3.groovyContent negotiation is driven by the “Accept” headerget: curl -H “Accept: application/json” http://localhost:5050
  • demo4“gradle run” to run the app- IntelliJ support for Ratpack
  • demo4“gradle run” to run the app- IntelliJ support for Ratpack
  • demo4“gradle run” to run the app- IntelliJ support for Ratpack
  • demo5
  • demo5
  • demo5
  • demo6http://localhost:5050/http://localhost:5050/?name=Dan
  • demo6http://localhost:5050/eventhttp://localhost:5050/event/Dan
  • demo7http://localhost:5050/groovymn.png
  • demo7Run from the command line: build/install/demo7/bin/demo7
  • demo7Packaged app with runnable script: build/distributions/demo7.zip
  • demo7
  • demo7
  • demo7
  • demo7
  • demo7
  • demo7
  • demo7
  • demo7
  • … at a future meetuphttp://twitter.com/beckje01
  • Building Web Apps in Ratpack

    1. 1. Building Web Apps in Ratpack Daniel Woods October 2013
    2. 2. About Me @danveloper #editor /danveloper daniel.p.woods
    3. 3. 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
    4. 4. 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?
    5. 5. Quick Intro to Ratpack • Runnable from a Groovy script!
    6. 6. Quick Intro to Ratpack • Simple Groovy DSL for Handler chain
    7. 7. Quick Intro to Ratpack • Support for prefixed endpoints
    8. 8. Quick Intro to Ratpack • Handling content-type
    9. 9. More Complex Needs… • Gradle
    10. 10. More Complex Needs… • Dependency Injection
    11. 11. More Complex Needs… • Modules
    12. 12. Getting all Dynamic… • Templates
    13. 13. Getting all Dynamic… • Templates
    14. 14. Getting all Dynamic… • Handlebars Template Support!
    15. 15. Accessing Parameters • request.queryParams
    16. 16. Accessing Parameters • context.pathTokens
    17. 17. Modularizing Handlers • MongoDBAssetHandler example
    18. 18. Building Ratpack • gradle installApp
    19. 19. Packaging Ratpack • gradle distZip
    20. 20. Deploying Ratpack • Heroku • Step 0 – Add the Gradle Wrapper to your Project
    21. 21. 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.
    22. 22. Deploying Ratpack • Heroku • Step 1 – Authenticate on Terminal
    23. 23. Deploying Ratpack • Heroku • Step 2 – Create your app with Heroku
    24. 24. Deploying Ratpack • Heroku • Step 3 – Configure the buildpack
    25. 25. 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
    26. 26. Deploying Ratpack • Heroku • Step 5 – Visit App
    27. 27. Deploying Ratpack • Heroku • Step 5 – Visit App
    28. 28. Testing Ratpack Apps Jeff Beck @beckje01
    29. 29. 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/
    30. 30. The End
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×