What are REST resources?

后端 未结 11 1188
青春惊慌失措
青春惊慌失措 2020-11-29 20:53

What are REST resources and how do they relate to resource names and resource representations?

I read a few articles on the subject, but they were too abstract and t

11条回答
  •  误落风尘
    2020-11-29 21:27

    What is REST?

    REST is an architecture Style which stands for Representational(RE) State(S) transfer(T).

    What is REST Resource ?

    Rest Resource is data on which we want to perform operation(s).So this data can be present in database as record(s) of table(s) or in any other form.This record has unique identifier with which it can be identified like id for Employee.

    Now when this data is requested by unique url like http://www.example.com/employees/123,so ultimately data or record which is present in database will be converted to JSON/XML/Plain text format by Rest Service and will be sent to Consumer.

    So basically,what is happening here is REPRESENTATIONAL STATE TRANSFER, in a way that state of the data present in database is transferred to another format which can be JSON/XML or plain text.

    So in this case 1 employee represents 1 resource which can be accessed by unique url like http://www.example.com/employees/123

    In case we want to get list of all resources(employees),we will do: http://www.example.com/employees

    Hope this will help.

提交回复
热议问题