Top Banner
RESTful with Drupal Easy and consistent data management presentation by Kalin Chernev
22
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: RESTful with Drupal - in-s and out-s

RESTful with DrupalEasy and consistent data management

presentation by Kalin Chernev

Page 2: RESTful with Drupal - in-s and out-s

Agenda

● What is REST?● 3 reasons to build and use RESTful APIs● Data management paradigm reminded● Data managed by Drupal● Data managed by a friend of Drupal● Considerations● Modules and tools● Resources

Page 3: RESTful with Drupal - in-s and out-s

About

● Drupalist from 2007● Trainer● Web developer

Page 4: RESTful with Drupal - in-s and out-s

What is REST

Architectural style describes six constraints- Uniform Interface- Stateless- Cacheable- Client-Server- Layered System- Code on Demand (optional)

Page 5: RESTful with Drupal - in-s and out-s

Simple and consistent way to manage data

Page 6: RESTful with Drupal - in-s and out-s

Any device

Page 7: RESTful with Drupal - in-s and out-s

Any technology

Any technology stack which works via HTTP

Name your server language:Python, Ruby, Java, NodeJS, PHP, .NET ...

Page 8: RESTful with Drupal - in-s and out-s

Exchanging json files

Page 9: RESTful with Drupal - in-s and out-s

Request / Response

Page 10: RESTful with Drupal - in-s and out-s

Terminology to get you started

● Resource URI● Endpoint● JSON● REST client● REST server

Page 11: RESTful with Drupal - in-s and out-s

Remember?

Data management at all CMS systems, boils down to simple:

C R U D

Page 12: RESTful with Drupal - in-s and out-s

CASE 1: Drupal is REST Server

● We POST/GET jsons to manage Drupal● Data is managed in Drupal

Page 13: RESTful with Drupal - in-s and out-s

Playing with the CRUD methodsEndpoint Action Method

/api/node CREATE POST

/api/node VIEW ALL GET

/api/:node_id VIEW SINGLE GET

/api/:node_id UPDATE PUT

/api/:node_id DELETE DELETE

Page 14: RESTful with Drupal - in-s and out-s

In reality, one can almost always go a long way only using GET & POST

Page 15: RESTful with Drupal - in-s and out-s

CASE 2: Drupal is REST Client

● We POST/GET jsons to manage content outside Drupal

● Data is contained outside Drupal

Data is shown and managed in Drupal

Page 16: RESTful with Drupal - in-s and out-s

Drops REST API ServerEndpoint Action Method

/drops CREATE POST

/drops VIEW ALL GET

/drops/:drop_id VIEW SINGLE GET

/drops/:drop_id UPDATE PUT

/drops/:drop_id DELETE DELETE

Page 17: RESTful with Drupal - in-s and out-s

Drupal magic

● hook_menu● hook_theme● helpers and callbacks

Page 18: RESTful with Drupal - in-s and out-s

What do you get

● Consistency and standardization● Separate responsibilities of development● Easy work● Core in D8● Cacheable● Predictable development (to most part)

Page 19: RESTful with Drupal - in-s and out-s

Considerations

● API server uptime and performance● Large amounts of data transfer● Security● Data validation● Error handling● Apache configurations to hide server

address