SlideShare a Scribd company logo
Submit Search
Upload
Login
Signup
Getting Rest With Webmachine
Report
kevsmith
Follow
Nov. 17, 2009
•
0 likes
•
5,723 views
1
of
51
Getting Rest With Webmachine
Nov. 17, 2009
•
0 likes
•
5,723 views
Report
Technology
News & Politics
Learn how to use webmachine to build a RESTful web application in Erlang.
kevsmith
Follow
Recommended
groovy & grails - lecture 3
Alexandre Masselot
748 views
•
80 slides
Php variables (english)
Mahmoud Masih Tehrani
1.5K views
•
25 slides
Introduction to PHP
prabhatjon
4.1K views
•
130 slides
Unfiltered Unveiled
Wilfred Springer
3.3K views
•
27 slides
PHP for Grown-ups
Manuel Lemos
1.5K views
•
69 slides
Beginning web programming with PHP [PHP 101-02]
Mozammel Haque
752 views
•
11 slides
More Related Content
What's hot
Php Lecture Notes
Santhiya Grace
4.6K views
•
42 slides
PHP variables
Siddique Ibrahim
5.4K views
•
46 slides
PHP POWERPOINT SLIDES
Ismail Mukiibi
3.8K views
•
19 slides
Php mysql
Alebachew Zewdu
7.8K views
•
40 slides
Class 2 - Introduction to PHP
Ahmed Swilam
810 views
•
39 slides
My cool new Slideshow!
omprakash_bagrao_prdxn
2.6K views
•
40 slides
What's hot
(14)
Php Lecture Notes
Santhiya Grace
•
4.6K views
PHP variables
Siddique Ibrahim
•
5.4K views
PHP POWERPOINT SLIDES
Ismail Mukiibi
•
3.8K views
Php mysql
Alebachew Zewdu
•
7.8K views
Class 2 - Introduction to PHP
Ahmed Swilam
•
810 views
My cool new Slideshow!
omprakash_bagrao_prdxn
•
2.6K views
slidesharenew1
truptitasol
•
2.5K views
Opa hackathon
Henri Binsztok
•
516 views
Intermediate PHP
Bradley Holt
•
2.5K views
Web 9 | OOP in PHP
Mohammad Imam Hossain
•
121 views
RCEC Email 4.7.03 (b)
Obama White House
•
1K views
Introduction to PHP - Basics of PHP
wahidullah mudaser
•
273 views
Intro to php
Sp Singh
•
241 views
OpenGurukul : Language : PHP
Open Gurukul
•
10.9K views
Viewers also liked
TravisCIでErlang/OTP (最小構成版)
Masatoshi Itoh
722 views
•
12 slides
中高生向けUnity講座
Makoto Ito
1.1K views
•
116 slides
Unityで使うRabbitMQ
Masatoshi Itoh
2.9K views
•
12 slides
非同期データ更新のためにメッセージキューを導入した(い)話
Takaaki Hirano
920 views
•
48 slides
Elixirについて私が知ってる二、三の事柄
Tsunenori Oohara
7.9K views
•
29 slides
Shibuya.ex #1 Elixirを本番環境で使ってみたという事例紹介
Tsunenori Oohara
16.5K views
•
16 slides
Viewers also liked
(9)
TravisCIでErlang/OTP (最小構成版)
Masatoshi Itoh
•
722 views
中高生向けUnity講座
Makoto Ito
•
1.1K views
Unityで使うRabbitMQ
Masatoshi Itoh
•
2.9K views
非同期データ更新のためにメッセージキューを導入した(い)話
Takaaki Hirano
•
920 views
Elixirについて私が知ってる二、三の事柄
Tsunenori Oohara
•
7.9K views
Shibuya.ex #1 Elixirを本番環境で使ってみたという事例紹介
Tsunenori Oohara
•
16.5K views
パーフェクト"Elixir情報収集"
Keisuke Takahashi
•
18K views
地獄のElixir(目黒スタートアップ勉強会)
Tsunenori Oohara
•
12.8K views
Erlangご紹介 websocket編
Masatoshi Itoh
•
2.8K views
Similar to Getting Rest With Webmachine
swift-nio のアーキテクチャーと RxHttpClient
Shinya Mochida
1.2K views
•
46 slides
Living With Legacy Code
Rowan Merewood
25.3K views
•
80 slides
Anatomy of a PHP Request ( UTOSC 2010 )
Joseph Scott
1.9K views
•
40 slides
Presto anatomy
Dongmin Yu
5K views
•
50 slides
iOS 개발자의 Flutter 체험기
Wanbok Choi
1.4K views
•
80 slides
Testing TYPO3 Applications
André Wuttig
1.4K views
•
56 slides
Similar to Getting Rest With Webmachine
(18)
swift-nio のアーキテクチャーと RxHttpClient
Shinya Mochida
•
1.2K views
Living With Legacy Code
Rowan Merewood
•
25.3K views
Anatomy of a PHP Request ( UTOSC 2010 )
Joseph Scott
•
1.9K views
Presto anatomy
Dongmin Yu
•
5K views
iOS 개발자의 Flutter 체험기
Wanbok Choi
•
1.4K views
Testing TYPO3 Applications
André Wuttig
•
1.4K views
Asynchronous I/O in PHP
Thomas Weinert
•
8.2K views
Javascript Continues Integration in Jenkins with AngularJS
Ladislav Prskavec
•
3.7K views
How to Write Node.js Module
Fred Chien
•
9.7K views
Lecture: Vaadin Overview
Joonas Lehtinen
•
1.3K views
Taipei.py 2018 - Control device via ioctl from Python
Hua Chu
•
1.2K views
Beginner workshop to angularjs presentation at Google
Ari Lerner
•
3K views
Plack at YAPC::NA 2010
Tatsuhiko Miyagawa
•
3.7K views
[245] presto 내부구조 파헤치기
NAVER D2
•
10.1K views
Performance measurement and tuning
AOE
•
2.3K views
Mojolicious. Веб в коробке!
Anatoly Sharifulin
•
789 views
Lecture2_IntroductionToPHP_Spring2023.pdf
ShaimaaMohamedGalal
•
9 views
Web Scraping with PHP
Matthew Turland
•
4.4K views
Recently uploaded
Common WordPress APIs - Options API
Jonathan Bossenger
28 views
•
10 slides
Experts Live Europe 2023 - Ensure your compliance in Microsoft Teams with Mic...
Jasper Oosterveld
77 views
•
76 slides
Getting your enterprise ready for Microsoft 365 Copilot
Vignesh Ganesan I Microsoft MVP
146 views
•
38 slides
UiPath Tips and Techniques for Error Handling - Session 2
DianaGray10
31 views
•
9 slides
Meetup_adessoCamunda_2023-09-13_Part1&2_en.pdf
MariaAlcantara50
36 views
•
31 slides
Mitigating Third-Party Risks: Best Practices for CISOs in Ensuring Robust Sec...
TrustArc
51 views
•
21 slides
Recently uploaded
(20)
Common WordPress APIs - Options API
Jonathan Bossenger
•
28 views
Experts Live Europe 2023 - Ensure your compliance in Microsoft Teams with Mic...
Jasper Oosterveld
•
77 views
Getting your enterprise ready for Microsoft 365 Copilot
Vignesh Ganesan I Microsoft MVP
•
146 views
UiPath Tips and Techniques for Error Handling - Session 2
DianaGray10
•
31 views
Meetup_adessoCamunda_2023-09-13_Part1&2_en.pdf
MariaAlcantara50
•
36 views
Mitigating Third-Party Risks: Best Practices for CISOs in Ensuring Robust Sec...
TrustArc
•
51 views
Product Listing Presentation_Cathy.pptx
CatarinaTorrenuevaMa
•
75 views
Die ultimative Anleitung für HCL Nomad Web Administratoren
panagenda
•
64 views
Framing Few Shot Knowledge Graph Completion with Large Language Models
MODUL Technology GmbH
•
39 views
Navigating the Future
OnBoard
•
32 views
Scaling out with WordPress
Konstantin Kovshenin
•
57 views
Machine learning with quantum computers
Speck&Tech
•
83 views
Webhook Testing Strategy
Dimpy Adhikary
•
65 views
Elevate Your Enterprise with FME 23.1
Safe Software
•
361 views
Advancing Equity and Inclusion for Deaf Students in Higher Education
3Play Media
•
153 views
web test repair.pptx
YuanzhangLin
•
40 views
Future of Skills
Alison B. Lowndes
•
64 views
info_session_gdsc_tmsl .pptx
NikitaSingh741518
•
30 views
Unleashing Innovation: IoT Project with MicroPython
Vubon Roy
•
34 views
Nymity Framework: Privacy & Data Protection Update in 7 States
TrustArc
•
153 views
Getting Rest With Webmachine
1.
Getting Some
REST with webmachine Kevin A. Smith
2.
What is webmachine?
3.
Framework
4.
Framework
5.
Toolkit
6.
A toolkit for building
RESTful HTTP resources
7.
What is REST?
8.
Style not a
standard
9.
Resources == URLs
10.
http://localhost:8000/hello_world
11.
http://foo.com/hr/emp/123
12.
GET POST DELETE
PUT
13.
REST is the
shape of the web
14.
-module(hello_world_resource). -export([init/1, to_html/2]). -include_lib("webmachine/include/webmachine.hrl"). init([]) ->
{ok, "Hello, world"}. to_html(Req, State) -> Output = io_lib:format(“<html><body>~s</body></html>”, [State]), {Output, Req, State}.
15.
-module(hello_world_resource). -export([init/1, to_html/2]). -include_lib("webmachine/include/webmachine.hrl"). init([]) ->
{ok, "Hello, world"}. to_html(Req, State) -> Output = io_lib:format(“<html><body>~s</body></html>”, [State]), {Output, Req, State}.
16.
-module(hello_world_resource). -export([init/1, to_html/2]). -include_lib("webmachine/include/webmachine.hrl"). init([]) ->
{ok, "Hello, world"}. to_html(Req, State) -> Output = io_lib:format(“<html><body>~s</body></html>”, [State]), {Output, Req, State}.
17.
-module(hello_world_resource). -export([init/1, to_html/2]). -include_lib("webmachine/include/webmachine.hrl"). init([]) ->
{ok, "Hello, world"}. to_html(Req, State) -> Output = io_lib:format(“<html><body>~s</body></html>”, [State]), {Output, Req, State}.
18.
-module(hello_world_resource). -export([init/1, to_html/2]). -include_lib("webmachine/include/webmachine.hrl"). init([]) ->
{ok, "Hello, world"}. to_html(Req, State) -> Output = io_lib:format(“<html><body>~s</body></html>”, [State]), {Output, Req, State}.
19.
A toolkit for
easily building RESTful HTTP resources
20.
GET /test HTTP/1.1 Host:
localhost:8000 User-Agent: Mozilla/5.0 Accept: text/html;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: UTF-8,* Keep-Alive: 300 Connection: keep-alive HTTP/1.x 200 OK Server: MochiWeb/1.1 WebMachine/1.3 Date: Mon, 22 Jun 2009 02:27:46 GMT Content-Type: text/html Content-Length: 78
21.
-module(hello_world_resource). -export([init/1, to_html/2]). -export([generate_etag/2]). -include_lib("webmachine/include/webmachine.hrl"). init([]) ->
{ok, "Hello, world"}. to_html(Req, State) -> Output = io_lib:format(“<html><body>~s</body></html>”, [State]), {Output, Req, State}. generate_etag(Req, State) -> {mochihex:to_hex(crypto:md5(State)), Req, State}.
22.
GET /test HTTP/1.1 Host:
localhost:8000 User-Agent: Mozilla/5.0 Accept: text/html;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: UTF-8,* Keep-Alive: 300 Connection: keep-alive HTTP/1.x 200 OK Server: MochiWeb/1.1 WebMachine/1.3 Etag: bc6e6f16b8a077ef5fbc8d59d0b931b9 Date: Mon, 22 Jun 2009 02:29:46 GMT Content-Type: text/html Content-Length: 78
23.
GET /test HTTP/1.1 Host:
localhost:8000 . . . If-None-Match: bc6e6f16b8a077ef5fbc8d59d0b931b9 HTTP/1.x 304 Not Modified Server: MochiWeb/1.1 WebMachine/1.3 Etag: bc6e6f16b8a077ef5fbc8d59d0b931b9 Date: Mon, 22 Jun 2009 02:30:00 GMT
24.
-module(hello_world_resource). -export([init/1, to_html/2]). -export([generate_etag/2, encodings_provided/2]). -include_lib("webmachine/include/webmachine.hrl"). init([])
-> {ok, "Hello, world"}. to_html(Req, State) -> Output = io_lib:format(“<html><body>~s</body></html>”, [State]), {Out, Req, State}. generate_etag(Req, State) -> {mochihex:to_hex(crypto:md5(State)), Req, State}. encodings_provided(Req, State) -> {[{"gzip", fun(X) -> zlib:gzip(X) end}], Req, State}.
25.
GET /test HTTP/1.1 Host:
localhost:8000 . . . Accept-Encoding: gzip,deflate HTTP/1.x 200 OK Server: MochiWeb/1.1 WebMachine/1.3 Etag: bc6e6f16b8a077ef5fbc8d59d0b931b9 Date: Mon, 22 Jun 2009 02:46:57 GMT Content-Type: text/html Content-Length: 71 Content-Encoding: gzip
26.
HTTP Is Hard
29.
PUT ERROR
CODES vs. PO ST O N I TI AT ENC O ODI NEG N GS T T EN IDEMPOTENCY N N IO C O IR AT X P STREA E MING T OVE T EN ET RLOA O N G DED C A L POS O N Ts I TI ND CO
30.
Request Routing
31.
http://foo.com/items {["items"], grocery_item_resource, []}.
URL path Resource module Init params
32.
http://foo.com/items/chocolate {["items", item], grocery_item_resource,
[]}. URL path URL variable Resource module Init params
33.
GET
34.
-module(hello_world_resource). -export([init/1,to_html/2]). -include_lib("webmachine/include/webmachine.hrl"). init([]) ->
{ok, "Hello, world"}. to_html(Req, State) -> Output = io_lib:format(“<html><body>~s</body></html>”, [State]), {Output, Req, State}.
35.
Must be idempotent
36.
PUT
37.
-module(grocery_list_resource). -export([init/1,allowed_methods/2]). -export([content_types_accepted/2,from_json/2]). -include_lib("webmachine/include/webmachine.hrl"). init([]) ->
{ok, []}. allowed_methods(Req, State) -> {[‘PUT’], Req, State}. content_types_accepted(Req, State) -> {[{“application/json”, from_json}], Req, State}. from_json(Req, State) -> %% Create/update logic here
38.
DELETE
39.
-module(grocery_list_resource). -export([init/1,allowed_methods/2]). -export([delete_resource/2]). -include_lib("webmachine/include/webmachine.hrl"). init([]) ->
{ok, []}. allowed_methods(Req, State) -> {[‘DELETE’], Req, State}. delete_resource(Req, State) -> %% Deletion logic here
40.
POST
41.
Hmmmm
42.
Problems with
POST
43.
Problems with
POST • Overloaded semantics
44.
Problems with
POST • Overloaded semantics • Create or update?
45.
Creation via
POST •allowed_methods/2 •post_is_create/2 •create_path/2 •content_types_accepted/2 • handler function
46.
Update via
POST •allowed_methods/2 •content_types_accepted/2 • handler function
47.
CODE TIME
48.
HTTP Request
Access
49.
HTTP Request • “Wrapped”
mochiweb request • Separate process for each request • Direct access to: request/response headers, response body, etc.
50.
Other Cool
Stuff • Graphical request debugging • Streaming requests and responses • File uploads
51.
webmachine source:
http://bitbucket.org/justin/webmachine Slides and demo code: http://github.com/kevsmith/erlang_factory/tree/master