REST API Server

I often hear or read the term REST API Server .

I am a code with PHP, and I made an API for my projects in the past that could return data in XML and JSON formats, and they were in REST form, where you would do something like

server.com/comments/123 To return / view comment using ID 123
server.com/comments/post to leave a comment
server.com/comments/123/edit to edit comment with ID 123
server.com/comments/123/delete to delete comment with code 123

Now I would not consider this a REST server, but I think it is a REST?

Can someone clarify or explain if I am wrong? I mean, is there more for a REST server, and is it just a term used or is a REST server completely different from the function described above?

I will soon have a project that will require a RESTful API, so I would like to make sure that I am doing this correctly.

+4
source share
2 answers

A similar question recently appeared: What are RESTful web services . Let it read.

In addition, there is a ton of REST information on the Internet. Here is one of the best reviews I've seen: http://www.xfront.com/REST-Web-Services.html .

In short, your service is not RESTful, but it is close. Instead of specifying actions (edit, delete, ...) in the URL segments, you will want to use HTTP verbs (GET, PUT, POST, DELETE). These details are discussed in the links provided.

+7
source

I think the REST standard is broad, and although you do not implement your own HTTP methods, your web service can be considered as a REST server. Personally, I do not think that the use of custom HTTP methods is always reasonable; many firewalls do not like this. I would perform the action (CREATE / DELETE / UPDATE) as part of the path or as part of the POST data (possibly as a JSON property).

See more of my recommended recommendations here: http://restafar.com/create-new-rest-server/

0
source

Source: https://habr.com/ru/post/1386439/


All Articles