SlideShare una empresa de Scribd logo
1 de 27
Unfiltered
Unveiled
  THE UNFRAMEWORK
Whoami
Code / train Scala for a living
Lately for a NYC startup
Using Unfiltered


Currently freelancer
Former Xebia
Former TomTom
Former Sun Microstems
Former ...
HTTP
    →
GET / HTTP/1.1
Host: nxt.flotsam.nl
                           ←
                      HTTP/1.1 200 OK
                      Date: Mon, 29 Oct 2012
                      …
                      Last-Modified: Wed, 17
Accept: text/html     …
                      ETag:
                      "4ce43eb8b40a4f…"
                      Content-Type: text/html
                      Content-Length: 9636
                      Server: AmazonS3
Frameworks
Solve many
problems around
given domain
Frameworks
Simple problems ☹
Toolkit



Loosely coupled
components that can be
composed to solve           Simple problems ☺
different problems          Complex problems ☺
HTTP

Stuff   Stuff
HTTP

Request   Response
Web Appl.
Request Response
Request’ Response’
Request’’ Response’’
Request’’’ Response’’’
That rings a bell
 … match {
  case … =>   …
  case … =>   …
  case … =>   …
  case … =>   …
Pattern matching
 obj match {
   case i: Int => i * 2
   case s: String => s + s
 }
Partial Function
 {
     case   …   =>   …
     case   …   =>   …
     case   …   =>   …
     case   …   =>   …
Example
val duplicate: PartialFunction[Any,Any] = {
  case s: String => s + s
  case i: Int => i * 2
}

duplicate(3)    // 6
duplicate("yuk") // "yukyuk”
duplicate(4.3) // MatchError
Unfiltered
{                                         Intent
    case _ => ResponseString(“yay”)
}



    GET / HTTP/           HTTP/1.1 200 OK
                          Content-Length: 3
Hitting the road
 import unfiltered.filter._
 import unfiltered.jetty._
 import unfiltered.response._

 Http(8090).filter(Planify {
   case _ => ResponseString("Ok")
 }).run
ResponseFunction ①
 case … => …
 case … => … ~> … ~> …



 Ok                  Html(…)
 NotFound            Html5(…)
 ResponseString(…)   JsonContent
 Json(…)             TextXmlContent
 ResponseWriter(…)   Redirect(…)
ResponseFunction ②
 Ok ~> PlainTextContent ~> ResponseString("foo")


 Ok→                      resp.setStatus(SC_OK)

 PlainTextContent→        resp.setContextType("text/plain")

 RepsonseString("foo")→   resp.setCharacterEncoding("UTF-8")
                          val writer = resp.getWriter()
                          writer.print("foo")
                          writer.close
ResponseFunction ③
 Ok ~> PlainTextContent ~> ResponseString("foo")

 NotFound ~> HtmlContent ~> Html(<html>
  <body>Not found</body>
 </html>)

 Redirect("/index.html")
Scalate
             Templates for Scala

                                               SSP
<% val decks: List[Decks] %>                   SCAML
<html>
<body>
                                               Mustache
<ul>                                           …
<% for (deck <- decks) { %>
<li><%= deck.name%></li>
<% } %>                       -@ val decks: List[Decks]
</ul>                         %html
</body>      <html>            %body
</html>      <body>             %ul
             <ul>                - for (deck <- decks)
             {{#decks}}           %li= deck.name
             <li>{{name}}</li>
             {{/decks}}
SCAML
                   In a Nutshell


!!!              <!DOCTYPE html PUBLIC "-//…
%html               <html>
  %body              <body>
    .masthead         <div class="masthead"/>
    #main           <div id="main"/>
    %p(onclick="") YES <p onclick="">YES</p>
    :javascript      <script language="javascript"/>
    :markdown
      *Nice*        <p><em>Nice</em></p>
                 </body>
                 </html>
Extractors ①
      case … => …
      case … & … & … => …


GET(…)            Accept(…)
POST(…)           UserAgent(…)
DELETE(…)         Host(…)
PUT(…)            IfModifiedSince(…)
Path(…)           Referer(…)
Extractors ②
case GET(_)

case GET(Path(path))

case Path(Seg("give","me",something :: Nil))
(Matches "/give/me/money", setting something to "money".)


case Path("/") & Params(params)

case Accept("application/json")
Extractors ③
HttpRequest[A] → { case … => … }


object DotJson {
  unapply[A](req: HttpRequest[A]) =
   req.uri.endsWith(".json")
}

case DotJson() => ResponseString("Json!")
QParams ☣
              MONAD ALERT

import unfiltered.request.QParams._
case req @ Params(params) =>
 val expected = for {
   lat <- lookup("lat") is required("missing")
   lon <- lookup("lon") is required("missing")
 } yield {
   Ok ~>
   PlainTextContent ~>
   ResponseString("%s, %s".format(lat.get, lon.get))
 }
 expected(params) orFail { failures =>
   BadRequest ~> ResponseString(failures.mkString)
But wait,
       there's more


-   OAuth
-   Secure switch          -   Upload
-   Routing kit            -   Netty binding
-   Basic authentication   -   Web Sockets
Key takeaways
Simple ☺
Retain control   ☺
Used for real apps   ☺
Hit the ground running ☺
Encode your own policies ☺
The source code is the documentation ⚇
Typesafe & extensible ☺☺☺
Vibe ☹
Questions?




fl
    Wilfred Springer
    wilfred@flotsam.nl
    http://nxt.flotsam.nl/

Más contenido relacionado

La actualidad más candente

Presentation on php string function part-1
Presentation on php string function part-1Presentation on php string function part-1
Presentation on php string function part-1Mysoftheaven (BD) Ltd.
 
Solr & Lucene @ Etsy by Gregg Donovan
Solr & Lucene @ Etsy by Gregg DonovanSolr & Lucene @ Etsy by Gregg Donovan
Solr & Lucene @ Etsy by Gregg DonovanGregg Donovan
 
Presentation on php string function part-2
Presentation on php string function part-2Presentation on php string function part-2
Presentation on php string function part-2Mysoftheaven (BD) Ltd.
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHPThomas Weinert
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webclkao
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHPmarkstory
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous phpWim Godden
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用Felinx Lee
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3markstory
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous phpWim Godden
 
Real time server
Real time serverReal time server
Real time serverthepian
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersIan Barber
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionIan Barber
 
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...takeoutweight
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveEleanor McHugh
 
Template Haskell Tutorial
Template Haskell TutorialTemplate Haskell Tutorial
Template Haskell Tutorialkizzx2
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 

La actualidad más candente (20)

Presentation on php string function part-1
Presentation on php string function part-1Presentation on php string function part-1
Presentation on php string function part-1
 
Solr & Lucene @ Etsy by Gregg Donovan
Solr & Lucene @ Etsy by Gregg DonovanSolr & Lucene @ Etsy by Gregg Donovan
Solr & Lucene @ Etsy by Gregg Donovan
 
groovy & grails - lecture 2
groovy & grails - lecture 2groovy & grails - lecture 2
groovy & grails - lecture 2
 
Presentation on php string function part-2
Presentation on php string function part-2Presentation on php string function part-2
Presentation on php string function part-2
 
Quebec pdo
Quebec pdoQuebec pdo
Quebec pdo
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
 
Real time server
Real time serverReal time server
Real time server
 
Teaching Your Machine To Find Fraudsters
Teaching Your Machine To Find FraudstersTeaching Your Machine To Find Fraudsters
Teaching Your Machine To Find Fraudsters
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
Living with garbage
Living with garbageLiving with garbage
Living with garbage
 
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Template Haskell Tutorial
Template Haskell TutorialTemplate Haskell Tutorial
Template Haskell Tutorial
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 

Destacado

Поиск экспортных ниш в образовательной робототехнике
Поиск экспортных ниш в образовательной робототехникеПоиск экспортных ниш в образовательной робототехнике
Поиск экспортных ниш в образовательной робототехникеTheodor Chihalin
 
Двумерное моделирование и детали для роботов
Двумерное моделирование и детали для роботовДвумерное моделирование и детали для роботов
Двумерное моделирование и детали для роботовAnton Moiseev
 
Как бы нам тоже делать роботов
Как бы нам тоже делать роботовКак бы нам тоже делать роботов
Как бы нам тоже делать роботовAnton Moiseev
 
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseSingle Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseRalf Sternberg
 
Популярная робототехника и 3д-печать
Популярная робототехника и 3д-печатьПопулярная робототехника и 3д-печать
Популярная робототехника и 3д-печатьAnton Moiseev
 
Очереди и блокировки. Теория и практика / Александр Календарев (ad1.ru)
Очереди и блокировки. Теория и практика / Александр Календарев (ad1.ru)Очереди и блокировки. Теория и практика / Александр Календарев (ad1.ru)
Очереди и блокировки. Теория и практика / Александр Календарев (ad1.ru)Ontico
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)Stephen Chin
 

Destacado (7)

Поиск экспортных ниш в образовательной робототехнике
Поиск экспортных ниш в образовательной робототехникеПоиск экспортных ниш в образовательной робототехнике
Поиск экспортных ниш в образовательной робототехнике
 
Двумерное моделирование и детали для роботов
Двумерное моделирование и детали для роботовДвумерное моделирование и детали для роботов
Двумерное моделирование и детали для роботов
 
Как бы нам тоже делать роботов
Как бы нам тоже делать роботовКак бы нам тоже делать роботов
Как бы нам тоже делать роботов
 
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseSingle Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
 
Популярная робототехника и 3д-печать
Популярная робототехника и 3д-печатьПопулярная робототехника и 3д-печать
Популярная робототехника и 3д-печать
 
Очереди и блокировки. Теория и практика / Александр Календарев (ad1.ru)
Очереди и блокировки. Теория и практика / Александр Календарев (ad1.ru)Очереди и блокировки. Теория и практика / Александр Календарев (ad1.ru)
Очереди и блокировки. Теория и практика / Александр Календарев (ad1.ru)
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
 

Similar a Unfiltered Unveiled

And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportBen Scofield
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVMVaclav Pech
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part AKazuchika Sekiya
 
Effecient javascript
Effecient javascriptEffecient javascript
Effecient javascriptmpnkhan
 
Scala 3camp 2011
Scala   3camp 2011Scala   3camp 2011
Scala 3camp 2011Scalac
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To ScalaPeter Maas
 
Type safe embedded domain-specific languages
Type safe embedded domain-specific languagesType safe embedded domain-specific languages
Type safe embedded domain-specific languagesArthur Xavier
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers StealBen Scofield
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkBen Scofield
 
Tools for Making Machine Learning more Reactive
Tools for Making Machine Learning more ReactiveTools for Making Machine Learning more Reactive
Tools for Making Machine Learning more ReactiveJeff Smith
 
Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Workhorse Computing
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceMaarten Balliauw
 
Xslate sv perl-2013-7-11
Xslate sv perl-2013-7-11Xslate sv perl-2013-7-11
Xslate sv perl-2013-7-11Goro Fuji
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web PerformanceAdam Lu
 
Introduction to Prototype JS Framework
Introduction to Prototype JS FrameworkIntroduction to Prototype JS Framework
Introduction to Prototype JS FrameworkMohd Imran
 

Similar a Unfiltered Unveiled (20)

And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack Support
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
 
Effecient javascript
Effecient javascriptEffecient javascript
Effecient javascript
 
Scala 3camp 2011
Scala   3camp 2011Scala   3camp 2011
Scala 3camp 2011
 
JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
 
Type safe embedded domain-specific languages
Type safe embedded domain-specific languagesType safe embedded domain-specific languages
Type safe embedded domain-specific languages
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers Steal
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Tools for Making Machine Learning more Reactive
Tools for Making Machine Learning more ReactiveTools for Making Machine Learning more Reactive
Tools for Making Machine Learning more Reactive
 
Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to Space
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
Xslate sv perl-2013-7-11
Xslate sv perl-2013-7-11Xslate sv perl-2013-7-11
Xslate sv perl-2013-7-11
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web Performance
 
Introduction to Prototype JS Framework
Introduction to Prototype JS FrameworkIntroduction to Prototype JS Framework
Introduction to Prototype JS Framework
 

Más de Wilfred Springer (13)

Unfiltered Unveiled
Unfiltered UnveiledUnfiltered Unveiled
Unfiltered Unveiled
 
Scala in your organisation
Scala in your organisationScala in your organisation
Scala in your organisation
 
Simplicity
SimplicitySimplicity
Simplicity
 
Mongo
MongoMongo
Mongo
 
NoSQL
NoSQLNoSQL
NoSQL
 
NoSQL Rollercoaster
NoSQL RollercoasterNoSQL Rollercoaster
NoSQL Rollercoaster
 
Byzantine Generals
Byzantine GeneralsByzantine Generals
Byzantine Generals
 
Eventually Consistent
Eventually ConsistentEventually Consistent
Eventually Consistent
 
Into the Wild
Into the WildInto the Wild
Into the Wild
 
OOPSLA Talk on Preon
OOPSLA Talk on PreonOOPSLA Talk on Preon
OOPSLA Talk on Preon
 
Spring ME JavaOne
Spring ME JavaOneSpring ME JavaOne
Spring ME JavaOne
 
Spring ME
Spring MESpring ME
Spring ME
 
Preon (J-Fall 2008)
Preon (J-Fall 2008)Preon (J-Fall 2008)
Preon (J-Fall 2008)
 

Último

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Último (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

Unfiltered Unveiled

  • 2. Whoami Code / train Scala for a living Lately for a NYC startup Using Unfiltered Currently freelancer Former Xebia Former TomTom Former Sun Microstems Former ...
  • 3. HTTP → GET / HTTP/1.1 Host: nxt.flotsam.nl ← HTTP/1.1 200 OK Date: Mon, 29 Oct 2012 … Last-Modified: Wed, 17 Accept: text/html … ETag: "4ce43eb8b40a4f…" Content-Type: text/html Content-Length: 9636 Server: AmazonS3
  • 6. Toolkit Loosely coupled components that can be composed to solve Simple problems ☺ different problems Complex problems ☺
  • 7. HTTP Stuff Stuff
  • 8. HTTP Request Response
  • 9. Web Appl. Request Response Request’ Response’ Request’’ Response’’ Request’’’ Response’’’
  • 10. That rings a bell … match { case … => … case … => … case … => … case … => …
  • 11. Pattern matching obj match { case i: Int => i * 2 case s: String => s + s }
  • 12. Partial Function { case … => … case … => … case … => … case … => …
  • 13. Example val duplicate: PartialFunction[Any,Any] = { case s: String => s + s case i: Int => i * 2 } duplicate(3) // 6 duplicate("yuk") // "yukyuk” duplicate(4.3) // MatchError
  • 14. Unfiltered { Intent case _ => ResponseString(“yay”) } GET / HTTP/ HTTP/1.1 200 OK Content-Length: 3
  • 15. Hitting the road import unfiltered.filter._ import unfiltered.jetty._ import unfiltered.response._ Http(8090).filter(Planify { case _ => ResponseString("Ok") }).run
  • 16. ResponseFunction ① case … => … case … => … ~> … ~> … Ok Html(…) NotFound Html5(…) ResponseString(…) JsonContent Json(…) TextXmlContent ResponseWriter(…) Redirect(…)
  • 17. ResponseFunction ② Ok ~> PlainTextContent ~> ResponseString("foo") Ok→ resp.setStatus(SC_OK) PlainTextContent→ resp.setContextType("text/plain") RepsonseString("foo")→ resp.setCharacterEncoding("UTF-8") val writer = resp.getWriter() writer.print("foo") writer.close
  • 18. ResponseFunction ③ Ok ~> PlainTextContent ~> ResponseString("foo") NotFound ~> HtmlContent ~> Html(<html> <body>Not found</body> </html>) Redirect("/index.html")
  • 19. Scalate Templates for Scala SSP <% val decks: List[Decks] %> SCAML <html> <body> Mustache <ul> … <% for (deck <- decks) { %> <li><%= deck.name%></li> <% } %> -@ val decks: List[Decks] </ul> %html </body> <html> %body </html> <body> %ul <ul> - for (deck <- decks) {{#decks}} %li= deck.name <li>{{name}}</li> {{/decks}}
  • 20. SCAML In a Nutshell !!! <!DOCTYPE html PUBLIC "-//… %html <html> %body <body> .masthead <div class="masthead"/> #main <div id="main"/> %p(onclick="") YES <p onclick="">YES</p> :javascript <script language="javascript"/> :markdown *Nice* <p><em>Nice</em></p> </body> </html>
  • 21. Extractors ① case … => … case … & … & … => … GET(…) Accept(…) POST(…) UserAgent(…) DELETE(…) Host(…) PUT(…) IfModifiedSince(…) Path(…) Referer(…)
  • 22. Extractors ② case GET(_) case GET(Path(path)) case Path(Seg("give","me",something :: Nil)) (Matches "/give/me/money", setting something to "money".) case Path("/") & Params(params) case Accept("application/json")
  • 23. Extractors ③ HttpRequest[A] → { case … => … } object DotJson { unapply[A](req: HttpRequest[A]) = req.uri.endsWith(".json") } case DotJson() => ResponseString("Json!")
  • 24. QParams ☣ MONAD ALERT import unfiltered.request.QParams._ case req @ Params(params) => val expected = for { lat <- lookup("lat") is required("missing") lon <- lookup("lon") is required("missing") } yield { Ok ~> PlainTextContent ~> ResponseString("%s, %s".format(lat.get, lon.get)) } expected(params) orFail { failures => BadRequest ~> ResponseString(failures.mkString)
  • 25. But wait, there's more - OAuth - Secure switch - Upload - Routing kit - Netty binding - Basic authentication - Web Sockets
  • 26. Key takeaways Simple ☺ Retain control ☺ Used for real apps ☺ Hit the ground running ☺ Encode your own policies ☺ The source code is the documentation ⚇ Typesafe & extensible ☺☺☺ Vibe ☹
  • 27. Questions? fl Wilfred Springer wilfred@flotsam.nl http://nxt.flotsam.nl/

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n