SlideShare uma empresa 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/

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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)
 

Destaque

Поиск экспортных ниш в образовательной робототехнике
Поиск экспортных ниш в образовательной робототехникеПоиск экспортных ниш в образовательной робототехнике
Поиск экспортных ниш в образовательной робототехнике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
 

Destaque (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)
 

Semelhante 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
 

Semelhante 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
 

Mais 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

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
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
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 

Último (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
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
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 

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 do 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