What exactly is RESTful programming?

前端 未结 30 3224
Happy的楠姐
Happy的楠姐 2020-11-21 06:02

What exactly is RESTful programming?

30条回答
  •  醉梦人生
    2020-11-21 06:28

    REST is an architectural style which is based on web-standards and the HTTP protocol (introduced in 2000).

    In a REST based architecture, everything is a resource(Users, Orders, Comments). A resource is accessed via a common interface based on the HTTP standard methods(GET, PUT, PATCH, DELETE etc).

    In a REST based architecture you have a REST server which provides access to the resources. A REST client can access and modify the REST resources.

    Every resource should support the HTTP common operations. Resources are identified by global IDs (which are typically URIs).

    REST allows that resources have different representations, e.g., text, XML, JSON etc. The REST client can ask for a specific representation via the HTTP protocol (content negotiation).

    HTTP methods:

    The PUT, GET, POST and DELETE methods are typical used in REST based architectures. The following table gives an explanation of these operations.

    • GET defines a reading access of the resource without side-effects. The resource is never changed via a GET request, e.g., the request has no side effects (idempotent).
    • PUT creates a new resource. It must also be idempotent.
    • DELETE removes the resources. The operations are idempotent. They can get repeated without leading to different results.
    • POST updates an existing resource or creates a new resource.

提交回复
热议问题