TRE UBELEILIGE SANNHETER OM REST
COMPUTASDAG, 13. JUNI 2014
1
2
Fra: http://martinfowler.com/articles/richardsonMaturityModel.html
SANNHET #1:
GET-kall er aldri nullipotent
3
4
Fra: http://martinfowler.com/articles/richardsonMaturityModel.html
Hva betyr «nullipotent»?
5
Fra Wikipedia:
«The GET method is a safe method (or
nullipotent), meaning that calling it
produ...
6
Tomcat Access
Log
Moteksempler
●
Access log som REST-ressurs
●
Tilgangskontroll
– Three strikes-regel
●
Engangsnedlasting
7
SANNHET #2:
HTTP Response Codes ≠ «REST Response Codes»
8
9
Fra: http://martinfowler.com/articles/richardsonMaturityModel.html
10
Fra: http://www.restapitutorial.com/httpstatuscodes.html
11
Fra: http://www.restapitutorial.com/httpstatuscodes.html
12
Fra: http://www.restapitutorial.com/httpstatuscodes.html
13
Fra: http://www.restapitutorial.com/httpstatuscodes.html
Martin Fowler om HATEOAS
14
«The key elements that are supported
by the existence of the web are the
strong separation bet...
SANNHET #3:
HATEOAS YAGNI⇒
15
16
Fra: http://martinfowler.com/articles/richardsonMaturityModel.html
HATEOAS
17
Hypermedia as the engine of application
state
Fra Wikipedia:
«Clients make state transitions only
through actio...
Eksempel: Hire i EPIM LogisticsHub
18
<Hire id="h101442">
<CcuId>141705</CcuId>
<EnclosingHireIds>
<EnclosingHireId distan...
Eksempel: Hire i EPIM LogisticsHub
19
<Hire id="h101442">
<CcuId>141705</CcuId>
<EnclosingHireIds>
<EnclosingHireId distan...
Eksempel: Hire i EPIM LogisticsHub
20
<Hire id="h101442">
<CcuId>141705</CcuId>
<EnclosingHireIds>
<EnclosingHireId distan...
Eksempel: Hire i EPIM LogisticsHub, full HATEOAS
21
<Hire id="h101442">
<CcuId>141705</CcuId>
<EnclosingHireIds>
<Enclosin...
Martin Fowler om HATEOAS
22
«One obvious benefit of hypermedia
controls is that it allows the server to
change its URI sch...
Martin Fowler om HATEOAS
23
«A further benefit is that it helps client
developers explore the protocol. The
links give cli...
Kost/nytte av HATEOAS
Hva endrer seg oftest?
●
Oppførsel
●
Innhold
●
URLer
Hva er vanskelig å refaktorere?
●
Oppførsel
●
I...
Eksempel: Hire i EPIM LogisticsHub
25
<Hire id="h101442">
<CcuId>141705</CcuId>
<EnclosingHireIds>
<EnclosingHireId distan...
Eksempel: Hire i EPIM LogisticsHub
26
<Hire id="h101442">
<CcuId>141705</CcuId>
<EnclosingHireIds>
<EnclosingHireId distan...
HATEOAS
27
●
Bruker mye båndbredde
●
For å kunne slippe å refaktorere
noe som er lett å refaktorere
●
Og som nesten aldri ...
Upcoming SlideShare
Loading in …5
×

Tre ubeleilige sannheter om REST

322 views

Published on

Three Inconvenient Thruths about REST

Published in: Software, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
322
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Tre ubeleilige sannheter om REST

  1. 1. TRE UBELEILIGE SANNHETER OM REST COMPUTASDAG, 13. JUNI 2014 1
  2. 2. 2 Fra: http://martinfowler.com/articles/richardsonMaturityModel.html
  3. 3. SANNHET #1: GET-kall er aldri nullipotent 3
  4. 4. 4 Fra: http://martinfowler.com/articles/richardsonMaturityModel.html
  5. 5. Hva betyr «nullipotent»? 5 Fra Wikipedia: «The GET method is a safe method (or nullipotent), meaning that calling it produces no side-effects.»
  6. 6. 6 Tomcat Access Log
  7. 7. Moteksempler ● Access log som REST-ressurs ● Tilgangskontroll – Three strikes-regel ● Engangsnedlasting 7
  8. 8. SANNHET #2: HTTP Response Codes ≠ «REST Response Codes» 8
  9. 9. 9 Fra: http://martinfowler.com/articles/richardsonMaturityModel.html
  10. 10. 10 Fra: http://www.restapitutorial.com/httpstatuscodes.html
  11. 11. 11 Fra: http://www.restapitutorial.com/httpstatuscodes.html
  12. 12. 12 Fra: http://www.restapitutorial.com/httpstatuscodes.html
  13. 13. 13 Fra: http://www.restapitutorial.com/httpstatuscodes.html
  14. 14. Martin Fowler om HATEOAS 14 «The key elements that are supported by the existence of the web are the strong separation between safe (eg GET) and non-safe operations, together with using status codes to help communicate the kinds of errors you run into.» http://martinfowler.com/articles/richardsonMaturityModel.html
  15. 15. SANNHET #3: HATEOAS YAGNI⇒ 15
  16. 16. 16 Fra: http://martinfowler.com/articles/richardsonMaturityModel.html
  17. 17. HATEOAS 17 Hypermedia as the engine of application state Fra Wikipedia: «Clients make state transitions only through actions that are dynamically identified within hypermedia by the server. Except for simple fixed entry points to the application, a client does not assume that any particular action is available for any particular resources beyond those described in representations previously received from the server.»
  18. 18. Eksempel: Hire i EPIM LogisticsHub 18 <Hire id="h101442"> <CcuId>141705</CcuId> <EnclosingHireIds> <EnclosingHireId distance="1">a1</EnclosingHireId> </EnclosingHireIds> <OrgNo>123456789</OrgNo> <GlnLocation>1234567890123</GlnLocation> <StartDate>2013-10-09</StartDate> <EndDate>2013-11-08</EndDate> <Link href="/ccus/141705/hires/a1/hires/h101442" method="get" rel="self"/> <Link href="/ccus/141705" method="get" rel="Ccu"/> <Link href="/ccus/141705/hires/a1" method="get" rel="EnclosingHire"/> </Hire>
  19. 19. Eksempel: Hire i EPIM LogisticsHub 19 <Hire id="h101442"> <CcuId>141705</CcuId> <EnclosingHireIds> <EnclosingHireId distance="1">a1</EnclosingHireId> </EnclosingHireIds> <OrgNo>123456789</OrgNo> <GlnLocation>1234567890123</GlnLocation> <StartDate>2013-10-09</StartDate> <EndDate>2013-11-08</EndDate> <Link href="/ccus/141705/hires/a1/hires/h101442" method="get" rel="self"/> <Link href="/ccus/141705" method="get" rel="Ccu"/> <Link href="/ccus/141705/hires/a1" method="get" rel="EnclosingHire"/> </Hire>
  20. 20. Eksempel: Hire i EPIM LogisticsHub 20 <Hire id="h101442"> <CcuId>141705</CcuId> <EnclosingHireIds> <EnclosingHireId distance="1">a1</EnclosingHireId> </EnclosingHireIds> <OrgNo>123456789</OrgNo> <GlnLocation>1234567890123</GlnLocation> <StartDate>2013-10-09</StartDate> <EndDate>2013-11-08</EndDate> <Link href="/ccus/141705/hires/a1/hires/h101442" method="get" rel="self"/> <Link href="/ccus/141705" method="get" rel="Ccu"/> <Link href="/ccus/141705/hires/a1" method="get" rel="EnclosingHire"/> </Hire> 199 av totalt 477 tegn (42%)
  21. 21. Eksempel: Hire i EPIM LogisticsHub, full HATEOAS 21 <Hire id="h101442"> <CcuId>141705</CcuId> <EnclosingHireIds> <EnclosingHireId distance="1">a1</EnclosingHireId> </EnclosingHireIds> <OrgNo>123456789</OrgNo> <GlnLocation>1234567890123</GlnLocation> <StartDate>2013-10-09</StartDate> <EndDate>2013-11-08</EndDate> <Link href="/ccus/141705/hires/a1/hires/h101442" method="get" rel="self"/> <Link href="/ccus/141705" method="get" rel="Ccu"/> <Link href="/ccus/141705/hires/a1" method="get" rel="EnclosingHire"/> <Link href="/organizations/123456789" method="get" rel="Organization"/> <Link href="/organizations/123456789/locations/1234567890123" method="get" rel="Location"/> <Link href="/ccus/141705/hires/a1/hires/h101442/documents" method="post" rel="Documents"/> <Link href="/ccus/141705/hires/a1/hires/h101442" method="put" rel="update"/> <Link href="/ccus/141705/hires/a1/hires/h101442/hires" method="post" rel="addHire"/> </Hire> 620 av totalt 899 tegn (69%)
  22. 22. Martin Fowler om HATEOAS 22 «One obvious benefit of hypermedia controls is that it allows the server to change its URI scheme without breaking clients. As long as clients look up the “addTest” link URI then the server team can juggle all URIs other than the initial entry points.» http://martinfowler.com/articles/richardsonMaturityModel.html
  23. 23. Martin Fowler om HATEOAS 23 «A further benefit is that it helps client developers explore the protocol. The links give client developers a hint as to what may be possible next. It doesn't give all the information: both the “latest” and “cancel” controls point to the same URI – they need to figure out that one is a GET and the other a DELETE. But at least it gives them a starting point as to what to think about for more information and to look for a similar URI in the protocol documentation.» http://martinfowler.com/articles/richardsonMaturityModel.html
  24. 24. Kost/nytte av HATEOAS Hva endrer seg oftest? ● Oppførsel ● Innhold ● URLer Hva er vanskelig å refaktorere? ● Oppførsel ● Innhold ● URLer 24
  25. 25. Eksempel: Hire i EPIM LogisticsHub 25 <Hire id="h101442"> <CcuId>141705</CcuId> <EnclosingHireIds> <EnclosingHireId distance="1">b2</EnclosingHireId> <EnclosingHireId distance="2">a1</EnclosingHireId> </EnclosingHireIds> <OrgNo>123456789</OrgNo> <GlnLocation>1234567890123</GlnLocation> <StartDate>2013-10-09</StartDate> <EndDate>2013-11-08</EndDate> <Link href="/ccus/141705/hires/a1/hires/h101442" method="get" rel="self"/> <Link href="/ccus/141705" method="get" rel="Ccu"/> <Link href="/ccus/141705/hires/a1" method="get" rel="EnclosingHire"/> <Link href="/organizations/123456789" method="get" rel="Organization"/> <Link href="/organizations/123456789/locations/1234567890123" method="get" rel="Location"/> <Link href="/ccus/141705/hires/a1/hires/h101442/documents" method="post" rel="Documents"/> <Link href="/ccus/141705/hires/a1/hires/h101442" method="put" rel="update"/> <Link href="/ccus/141705/hires/a1/hires/h101442/hires" method="post" rel="addHire"/> </Hire>
  26. 26. Eksempel: Hire i EPIM LogisticsHub 26 <Hire id="h101442"> <CcuId>141705</CcuId> <EnclosingHireIds> <EnclosingHireId distance="1">b2</EnclosingHireId> <EnclosingHireId distance="2">a1</EnclosingHireId> </EnclosingHireIds> <OrgNo>123456789</OrgNo> <GlnLocation>1234567890123</GlnLocation> <StartDate>2013-10-09</StartDate> <EndDate>2013-11-08</EndDate> <Link href="/ccus/141705/hires/a1/hires/h101442" method="get" rel="self"/> <Link href="/ccus/141705" method="get" rel="Ccu"/> <Link href="/ccus/141705/hires/a1" method="get" rel="EnclosingHire"/> <Link href="/organizations/123456789" method="get" rel="Organization"/> <Link href="/organizations/123456789/locations/1234567890123" method="get" rel="Location"/> <Link href="/ccus/141705/hires/a1/hires/h101442/documents" method="post" rel="Documents"/> <Link href="/ccus/141705/hires/a1/hires/h101442" method="put" rel="update"/> <Link href="/ccus/141705/hires/a1/hires/h101442/hires" method="post" rel="addHire"/> </Hire>
  27. 27. HATEOAS 27 ● Bruker mye båndbredde ● For å kunne slippe å refaktorere noe som er lett å refaktorere ● Og som nesten aldri endrer seg ● YAGNI (You aren't gonna need it)

×