SlideShare une entreprise Scribd logo
1  sur  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/

Contenu connexe

Tendances

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
 

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

En vedette

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

En vedette (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)
 

Similaire à 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
 

Similaire à 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
 

Plus 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)
 

Dernier

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 

Dernier (20)

Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"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...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
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
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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?
 

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/

Notes de l'éditeur

  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