SlideShare a Scribd company logo
Play Framework
The big picture
The Big Picture (contd.)
1. Follows Async model of request response
○ Jetty
○ NIO
2. Not one thread per request
3. MVC design pattern separates application’s logic and data from the user
interface’s
4. Brings in Scala type safety to good use
5. Great DX
○ Errors are shown on the browser
○ Auto reload, no messy build and redeployment
The Big Picture (contd.)
How do you create one?
Use SBT
sbt new playframework/play-scala-seed.g8
And you get this common play project structure
Different parts of Play Framework => =>
1. The Routes file
GET / controllers.Application.index
POST /product controllers.Products.addProduct
GET /products controllers.Products.list
GET /product/:id controllers.Products.getProductById(id: Long)
GET /product/byName controllers.Products.getProductByName(name: String)
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
2. The Controller
● Extend your class with play.mvc.Controller
● Write methods to handle calls in the routes file
● The Action class
a. final def apply(block: => Result): Action[AnyContent]
b. final def async(block: => Future[Result]): Action[AnyContent]
c. final def async[A](bodyParser: BodyParser[A])(block: R[A] => Future[Result]):
Action[A]
● controllers, actions, requests, and responses as Scala traits in the
play.api.mvc package - controller layer API
● MVC API mixes the HTTP concepts (request, response), with MVC concepts
such as controllers and actions.
2. The Controller (contd.) => Important Classes/Traits
Corresponding to HTTP concepts
play.api.mvc.Cookie — An HTTP cookie: a small amount of data stored on the client and
sent with subsequent requests
play.api.mvc.Request — An HTTP request: HTTP method, URL, headers, body, and
cookies
play.api.mvc.RequestHeader — Request metadata: a name-value pair
play.api.mvc.Response — An HTTP response, with headers and a body; wraps a Play
Result
play.api.mvc.ResponseHeader — Response metadata: a name-value pair
2. The Controller (contd.) => Important Classes/Traits
Corresponding to MVC and extras
play.api.mvc.Action — A function that processes a client Request and returns a Result
play.api.mvc.Result — The result of calling an Action to process a Request, used to generate an
HTTP response
play.api.mvc.Call — An HTTP request: the combination of an HTTP method and a URL
play.api.mvc.Content — An HTTP response body with a particular content type
play.api.mvc.Controller — A generator for Action functions
play.api.mvc.Session — A set of string keys and values, stored in an HTTP cookie
3. The View/Template
1. Type safe template engine
2. HTML 5 mark up with Scala
3. Easy to compose
@import services.ProductsService.Product
@(products: List[Product])
@main("Demo Product Application") {
<dl class="products">
@for(product <- products) {
<dt>@product.name</dt>
<dd>@product.description</dd>
}
</dl>
}
4. Play JSON
1. Easy to write formats for models
2. Uses macro to generate JSON reads and writes
○ case class Product(id: Long, name: String, description: String)
○ implicit val productFormat = Json.format[Product]
3. Built on top of Jackson
5. Public Assets
GET /assets/*file controllers.Assets.at(path="/public", file)
1. Treated as any other route so easier to use the reverse route without using the
actual path in all the templates
2. *file part matches anything including the /
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
1. automatically manages ETag HTTP Headers.
2. When a web browser makes a request specifying this Etag then the server can
respond with 304 NotModified.
6. Internationalization with Messages
conf/messages—Default messages for all languages, for messages not localized
for a particular language
conf/messages.es—Spanish (which is called Español in Spanish)
conf/messages.fr—French (Français in French)
conf/messages.nl—Dutch (Nederlands in Dutch)
=> Inject MessagesApi and call the apply method with the key and varargs as
message arguments and you are done!
Request/Response Flow
play.api.mvc.Result — The result of calling an Action to process a Request, used to generate an
HTTP response
Resources
1. Play’s official docs - https://www.playframework.com/documentation
2. Play For Scala (Book) - https://www.manning.com/books/play-for-scala
3. Talks -
a. The Play Framework at LinkedIn: Productivity and Performance at Scale -
https://www.youtube.com/watch?v=8z3h4Uv9YbE
b. James Ward: Modern Play Apps with Play Framework -
https://www.youtube.com/watch?v=Dfek3hIVRtw
Thank You!

More Related Content

What's hot

Inner core of Ajax
Inner core of Ajax Inner core of Ajax
Inner core of Ajax
Muhammad Junaid Ansari
 
How to Recover Outlook PST File
How to Recover Outlook PST FileHow to Recover Outlook PST File
How to Recover Outlook PST File
adamvoges
 
2310 b 12
2310 b 122310 b 12
2310 b 12
Krazy Koder
 
SQLite 3
SQLite 3SQLite 3
SQLite 3
Scott MacVicar
 
Intro webapps
Intro webappsIntro webapps
Intro webapps
Howard Mao
 
App D
App DApp D
Database connectivity in python
Database connectivity in pythonDatabase connectivity in python
Database connectivity in python
baabtra.com - No. 1 supplier of quality freshers
 
Ajax and xml
Ajax and xmlAjax and xml
Ajax and xml
sawsan slii
 
2310 b 11
2310 b 112310 b 11
2310 b 11
Krazy Koder
 
Power shell basics day 7
Power shell basics day 7Power shell basics day 7
Power shell basics day 7
Ashish Raj
 
Sqlite
SqliteSqlite
Sqlite
Raghu nath
 
Asp db
Asp dbAsp db
Asp db
teach4uin
 
Query transport problems
Query transport problemsQuery transport problems
Query transport problems
Igor Prudnecionok
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for Android
Jakir Hossain
 

What's hot (14)

Inner core of Ajax
Inner core of Ajax Inner core of Ajax
Inner core of Ajax
 
How to Recover Outlook PST File
How to Recover Outlook PST FileHow to Recover Outlook PST File
How to Recover Outlook PST File
 
2310 b 12
2310 b 122310 b 12
2310 b 12
 
SQLite 3
SQLite 3SQLite 3
SQLite 3
 
Intro webapps
Intro webappsIntro webapps
Intro webapps
 
App D
App DApp D
App D
 
Database connectivity in python
Database connectivity in pythonDatabase connectivity in python
Database connectivity in python
 
Ajax and xml
Ajax and xmlAjax and xml
Ajax and xml
 
2310 b 11
2310 b 112310 b 11
2310 b 11
 
Power shell basics day 7
Power shell basics day 7Power shell basics day 7
Power shell basics day 7
 
Sqlite
SqliteSqlite
Sqlite
 
Asp db
Asp dbAsp db
Asp db
 
Query transport problems
Query transport problemsQuery transport problems
Query transport problems
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for Android
 

Similar to Play framework

Active Server Page - ( ASP )
Active Server Page - ( ASP )Active Server Page - ( ASP )
Active Server Page - ( ASP )
MohitJoshi154
 
07 response-headers
07 response-headers07 response-headers
07 response-headers
hanichandra
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
Techglyphs
 
Asp.net By Durgesh Singh
Asp.net By Durgesh SinghAsp.net By Durgesh Singh
Asp.net By Durgesh Singh
imdurgesh
 
asp_intro.pptx
asp_intro.pptxasp_intro.pptx
asp_intro.pptx
vijayalakshmi257551
 
Meet with Meteor
Meet with MeteorMeet with Meteor
Meet with Meteor
Tahmina Khatoon
 
Ibm
IbmIbm
Ibm
techbed
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 
Synopsis
SynopsisSynopsis
12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat
linoj
 
State management servlet
State management servletState management servlet
State management servlet
Thakur Amit Tomer
 
Having Fun Building Web Applications (Day 2 slides)
Having Fun Building Web Applications (Day 2 slides)Having Fun Building Web Applications (Day 2 slides)
Having Fun Building Web Applications (Day 2 slides)
Clarence Ngoh
 
Internet Explorer 8
Internet Explorer 8Internet Explorer 8
Internet Explorer 8
David Chou
 
Web storage
Web storage Web storage
Web storage
PratikDoiphode1
 
Introduction to Node JS1.pdf
Introduction to Node JS1.pdfIntroduction to Node JS1.pdf
Introduction to Node JS1.pdf
Bareen Shaikh
 
flask.pptx
flask.pptxflask.pptx
flask.pptx
asif290119
 
2310 b 15
2310 b 152310 b 15
2310 b 15
Krazy Koder
 
2310 b 15
2310 b 152310 b 15
2310 b 15
Krazy Koder
 
Wikilims Road4
Wikilims Road4Wikilims Road4
Wikilims Road4
guestcc22df
 
Cloud Computing in Systems Programming Curriculum
Cloud Computing in Systems Programming CurriculumCloud Computing in Systems Programming Curriculum
Cloud Computing in Systems Programming Curriculum
Steven Miller
 

Similar to Play framework (20)

Active Server Page - ( ASP )
Active Server Page - ( ASP )Active Server Page - ( ASP )
Active Server Page - ( ASP )
 
07 response-headers
07 response-headers07 response-headers
07 response-headers
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
 
Asp.net By Durgesh Singh
Asp.net By Durgesh SinghAsp.net By Durgesh Singh
Asp.net By Durgesh Singh
 
asp_intro.pptx
asp_intro.pptxasp_intro.pptx
asp_intro.pptx
 
Meet with Meteor
Meet with MeteorMeet with Meteor
Meet with Meteor
 
Ibm
IbmIbm
Ibm
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Synopsis
SynopsisSynopsis
Synopsis
 
12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat
 
State management servlet
State management servletState management servlet
State management servlet
 
Having Fun Building Web Applications (Day 2 slides)
Having Fun Building Web Applications (Day 2 slides)Having Fun Building Web Applications (Day 2 slides)
Having Fun Building Web Applications (Day 2 slides)
 
Internet Explorer 8
Internet Explorer 8Internet Explorer 8
Internet Explorer 8
 
Web storage
Web storage Web storage
Web storage
 
Introduction to Node JS1.pdf
Introduction to Node JS1.pdfIntroduction to Node JS1.pdf
Introduction to Node JS1.pdf
 
flask.pptx
flask.pptxflask.pptx
flask.pptx
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
Wikilims Road4
Wikilims Road4Wikilims Road4
Wikilims Road4
 
Cloud Computing in Systems Programming Curriculum
Cloud Computing in Systems Programming CurriculumCloud Computing in Systems Programming Curriculum
Cloud Computing in Systems Programming Curriculum
 

Recently uploaded

Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 

Recently uploaded (20)

Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 

Play framework

  • 3. The Big Picture (contd.) 1. Follows Async model of request response ○ Jetty ○ NIO 2. Not one thread per request 3. MVC design pattern separates application’s logic and data from the user interface’s 4. Brings in Scala type safety to good use 5. Great DX ○ Errors are shown on the browser ○ Auto reload, no messy build and redeployment
  • 4. The Big Picture (contd.)
  • 5. How do you create one? Use SBT sbt new playframework/play-scala-seed.g8 And you get this common play project structure
  • 6. Different parts of Play Framework => =>
  • 7. 1. The Routes file GET / controllers.Application.index POST /product controllers.Products.addProduct GET /products controllers.Products.list GET /product/:id controllers.Products.getProductById(id: Long) GET /product/byName controllers.Products.getProductByName(name: String) # Map static resources from the /public folder to the /assets URL path GET /assets/*file controllers.Assets.at(path="/public", file)
  • 8. 2. The Controller ● Extend your class with play.mvc.Controller ● Write methods to handle calls in the routes file ● The Action class a. final def apply(block: => Result): Action[AnyContent] b. final def async(block: => Future[Result]): Action[AnyContent] c. final def async[A](bodyParser: BodyParser[A])(block: R[A] => Future[Result]): Action[A] ● controllers, actions, requests, and responses as Scala traits in the play.api.mvc package - controller layer API ● MVC API mixes the HTTP concepts (request, response), with MVC concepts such as controllers and actions.
  • 9. 2. The Controller (contd.) => Important Classes/Traits Corresponding to HTTP concepts play.api.mvc.Cookie — An HTTP cookie: a small amount of data stored on the client and sent with subsequent requests play.api.mvc.Request — An HTTP request: HTTP method, URL, headers, body, and cookies play.api.mvc.RequestHeader — Request metadata: a name-value pair play.api.mvc.Response — An HTTP response, with headers and a body; wraps a Play Result play.api.mvc.ResponseHeader — Response metadata: a name-value pair
  • 10. 2. The Controller (contd.) => Important Classes/Traits Corresponding to MVC and extras play.api.mvc.Action — A function that processes a client Request and returns a Result play.api.mvc.Result — The result of calling an Action to process a Request, used to generate an HTTP response play.api.mvc.Call — An HTTP request: the combination of an HTTP method and a URL play.api.mvc.Content — An HTTP response body with a particular content type play.api.mvc.Controller — A generator for Action functions play.api.mvc.Session — A set of string keys and values, stored in an HTTP cookie
  • 11. 3. The View/Template 1. Type safe template engine 2. HTML 5 mark up with Scala 3. Easy to compose @import services.ProductsService.Product @(products: List[Product]) @main("Demo Product Application") { <dl class="products"> @for(product <- products) { <dt>@product.name</dt> <dd>@product.description</dd> } </dl> }
  • 12. 4. Play JSON 1. Easy to write formats for models 2. Uses macro to generate JSON reads and writes ○ case class Product(id: Long, name: String, description: String) ○ implicit val productFormat = Json.format[Product] 3. Built on top of Jackson
  • 13. 5. Public Assets GET /assets/*file controllers.Assets.at(path="/public", file) 1. Treated as any other route so easier to use the reverse route without using the actual path in all the templates 2. *file part matches anything including the / GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) 1. automatically manages ETag HTTP Headers. 2. When a web browser makes a request specifying this Etag then the server can respond with 304 NotModified.
  • 14. 6. Internationalization with Messages conf/messages—Default messages for all languages, for messages not localized for a particular language conf/messages.es—Spanish (which is called Español in Spanish) conf/messages.fr—French (Français in French) conf/messages.nl—Dutch (Nederlands in Dutch) => Inject MessagesApi and call the apply method with the key and varargs as message arguments and you are done!
  • 15. Request/Response Flow play.api.mvc.Result — The result of calling an Action to process a Request, used to generate an HTTP response
  • 16. Resources 1. Play’s official docs - https://www.playframework.com/documentation 2. Play For Scala (Book) - https://www.manning.com/books/play-for-scala 3. Talks - a. The Play Framework at LinkedIn: Productivity and Performance at Scale - https://www.youtube.com/watch?v=8z3h4Uv9YbE b. James Ward: Modern Play Apps with Play Framework - https://www.youtube.com/watch?v=Dfek3hIVRtw