putting hypermedia back in rest with jax-rs

16
Putting Hypermedia Back in REST with JAX-RS sebastian daschner

Upload: ptjug

Post on 07-Jan-2017

542 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Putting Hypermedia Back in REST with JAX-RS

Putting Hypermedia Back in REST with JAX-RS

sebastian daschner

Page 2: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

sebastian daschner

● Java developer / architect / consultant

● JAX-RS Expert Group member

● Java Champion

● conference speaker

Page 3: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

workshops / training

● workshops in Munich

● workshops in Oslo / Norway (TBA)

● virtually on demand

Page 4: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

“REST” APIs in real-world projects

Page 5: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

“REST” APIs in real-world projects

POST /doSomeActionrequest<someActionRequest> <param>12345</param></someActionRequest>

response<someActionResponse> <foo>bar</foo> ...</someActionResponse>

Page 6: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

“REST” APIs in real-world projects

POST /getFoobarInformationrequest<foobar> <id>12345</id></foobar>

response<information> <foo>bar</foo> ...</information>

Page 7: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

Resources

Page 8: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

“REST” APIs in real-world projects

GET /users

response<users> <user> <id>12345</id> <name>Duke</name> <motto>JAX-RS rocks!</motto> </user> ...</users>

Page 9: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

Semantic HTTP

Page 10: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

“REST” APIs in real-world projects

POST /usersrequest<user> <name>Duke</name> <motto>JAX-RS rocks!</motto></user>

response201 CreatedLocation: /users/12345

Page 11: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

Enter Hypermedia

Page 12: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

Enter Hypermedia

GET /users

response<users> <user> <name>Duke</name> <motto>JAX-RS rocks!</motto> <link rel="self" href="/users/1234"/> </user></users

Page 13: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

Enter Hypermedia

GET /books/12345

response{ "name": "Java", // + author, availability, price "_links": { "self": "/books/12345", "add-to-cart": "/shopping_cart" }}

Page 14: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

Enter Hypermedia

..."actions": [ { "name": "add-to-cart", "method": "POST", "href": "/shopping_cart", "type": "application/json", "fields": [ { "name": "id", "type": "text" }, { "name": "quantity", "type": "number" } ] }]

Page 15: Putting Hypermedia Back in REST with JAX-RS

@DaschnerS

Hypermedia formats

● HAL

● Collections+JSON

● Siren

● JSON Schema

● JSON-LD & Hydra

● ...

Page 16: Putting Hypermedia Back in REST with JAX-RS

Thanks for your attention!

sebastian-daschner.comtwitter.com/DaschnerSgithub.com/sdaschner