Slide 1

Slide 1 text

Proper HTTP Building well-defined APIs, part 1: @neektza Nikica Jokić

Slide 2

Slide 2 text

HTTP is deceptively simple

Slide 3

Slide 3 text

• simple syntax, semantics up to you HTTP is deceptively simple

Slide 4

Slide 4 text

• simple syntax, semantics up to you • easy to build crappy, bad-behaving APIs HTTP is deceptively simple

Slide 5

Slide 5 text

• simple syntax, semantics up to you • easy to build crappy, bad-behaving APIs • use error status codes HTTP is deceptively simple

Slide 6

Slide 6 text

• simple syntax, semantics up to you • easy to build crappy, bad-behaving APIs • use error status codes • respect content-types (accept headers) HTTP is deceptively simple

Slide 7

Slide 7 text

• simple syntax, semantics up to you • easy to build crappy, bad-behaving APIs • use error status codes • respect content-types (accept headers) • handle resource migration and locations HTTP is deceptively simple

Slide 8

Slide 8 text

A huge SVG! http://for-get.github.io/http-decision-diagram/httpdd.fsm.html

Slide 9

Slide 9 text

Webmachine (1/2)

Slide 10

Slide 10 text

• Not a framework - a toolkit Webmachine (1/2)

Slide 11

Slide 11 text

• Not a framework - a toolkit • Implements the HTTP protocol as a state-machine Webmachine (1/2)

Slide 12

Slide 12 text

• Not a framework - a toolkit • Implements the HTTP protocol as a state-machine Webmachine (1/2)

Slide 13

Slide 13 text

• Not a framework - a toolkit • Implements the HTTP protocol as a state-machine Webmachine (1/2)

Slide 14

Slide 14 text

• Not a framework - a toolkit • Implements the HTTP protocol as a state-machine • Several implementations: Webmachine (1/2)

Slide 15

Slide 15 text

• Not a framework - a toolkit • Implements the HTTP protocol as a state-machine • Several implementations: • Webmachine (1st Erlang, then Ruby) Webmachine (1/2)

Slide 16

Slide 16 text

• Not a framework - a toolkit • Implements the HTTP protocol as a state-machine • Several implementations: • Webmachine (1st Erlang, then Ruby) • Liberator (Clojure) Webmachine (1/2)

Slide 17

Slide 17 text

• Not a framework - a toolkit • Implements the HTTP protocol as a state-machine • Several implementations: • Webmachine (1st Erlang, then Ruby) • Liberator (Clojure) • others? Webmachine (1/2)

Slide 18

Slide 18 text

A huge SVG! Again! http://for-get.github.io/http-decision-diagram/httpdd.fsm.html

Slide 19

Slide 19 text

Webmachine (2/2)

Slide 20

Slide 20 text

• Declarative Webmachine (2/2)

Slide 21

Slide 21 text

• Declarative Webmachine (2/2) get '/hello/:name' do "Hello #{params[:name]}!" end

Slide 22

Slide 22 text

• Declarative • Works by describing facts about the resource Webmachine (2/2) get '/hello/:name' do "Hello #{params[:name]}!" end

Slide 23

Slide 23 text

• Declarative • Works by describing facts about the resource Webmachine (2/2) get '/hello/:name' do "Hello #{params[:name]}!" end def resource_exists? resource end

Slide 24

Slide 24 text

• Declarative • Works by describing facts about the resource Webmachine (2/2) get '/hello/:name' do "Hello #{params[:name]}!" end def resource_exists? resource end • known-method? / method-allowed ? • known-media-type? / media-type-available? • allowed? / authorised? • exists? / existed? • moved-temporarily? / moved-permanently?