restful-url

Is it legal to have REST resource such as /currentUser in terms of RESTful and stateless?

☆樱花仙子☆ 提交于 2019-12-03 14:27:09
In terms of RESTful and stateless it's pretty legal to have resource like /users/123 But, the question is: is it legal to have resource that omits user id and assumes that it's implicitly resolved on the server from the user session? For example: /loggedUser That resource would point to /users/123 when user with identifier 123 is authorized. cassiomolin Picking a resource locator Using /me , /users/me , /users/myself , /users/current or similar URIs to identify a resource that corresponds to the authenticated user is perfectly fine from a REST perspective. According to Roy Thomas Fielding's

Do REST API URLs have to look like this?

女生的网名这么多〃 提交于 2019-12-03 08:59:09
问题 Is it true that to implement a RESTful API, one has to implement a URL structure that looks like this http://example.com/post/ http://example.com/post/123 where the /123 would be used for edit, delete Another way to ask the question is: can a URL that looks like this be called RESTful? http://example.com/script.php?method=get_title&blogid=123 回答1: You don't have to design your URI structure like that. It could also be /some_obscure_string/base64_encoded_title/unique_id . This could also be

Alternative to <a href=“#”> when the anchor tag only triggers a jQuery action without redirecting the user?

心不动则不痛 提交于 2019-12-03 07:52:00
I have numerous anchor tags on my page that only trigger jQuery actions on the same page. The don't redirect the user to another location, which is the normal expected behavior of an anchor tag. I don't want to have restful urls in my app for every action. But, I also don't like sending the user to the top of the page every time they click on one of these <a href="#"> tags. What's a better value to put inside the href value of the anchor tag besides # ? Can you reference a fragment on the page that could work as a logical fallback to the non-executed JavaScript action? If so, it makes a lot of

How to structure REST resource hierarchy?

让人想犯罪 __ 提交于 2019-12-03 06:57:57
问题 I'm new to server side web development and recently I've been reading a lot about implementing RESTful API's. One aspect of REST API's that I'm still stuck on is how to go about structuring the URI hierarchy that identifies resources that the client can interact with. Specifically I'm stuck on deciding how detailed to make the hierarchy and what to do in the case of resources being composed of other resource types. Here's an example that hopefully will show what I mean. Imagine we have a web

RESTful - What should a DELETE response body contain

陌路散爱 提交于 2019-12-03 05:25:54
问题 Let's say I have an API where you can get users: GET /RESTAPI/user/ And you can delete users by: DELETE /RESTAPI/user/123 What is the RESTful convention on what the DELETE's response body should contain? I expected it should be the new list of all users which now doesn't contain the user with id 123 anymore. Googling around didn't get me any satisfying answers. I only found opinions on how to do that, but isn't there a strict definition of RESTful Services ? This is NOT a duplicate of What

RESTful API routes design: nested vs. non-nested

こ雲淡風輕ζ 提交于 2019-12-03 05:20:40
My question is about the advantages of nesting resources when building URLs for API purposes. Consider the following two alternatives for accessing an employee resource: /api/employees?department=1 # flat Vs. /api/departments/1/employees # nested Now consider the task of developing a general purpose library to access REST resources from an API. If all routes were flat, such a REST wrapper library would only need to know the name of the resource being accessed: store.query('employees', {department_id:1}) => /api/employees?department=1 However, if we were to support nested routes, this wrapper

Do REST API URLs have to look like this?

社会主义新天地 提交于 2019-12-02 23:02:16
Is it true that to implement a RESTful API, one has to implement a URL structure that looks like this http://example.com/post/ http://example.com/post/123 where the /123 would be used for edit, delete Another way to ask the question is: can a URL that looks like this be called RESTful? http://example.com/script.php?method=get_title&blogid=123 You don't have to design your URI structure like that. It could also be /some_obscure_string/base64_encoded_title/unique_id . This could also be RESTful, depending on several other factors. But there are several best practices on how to design URIs in a

How to structure REST resource hierarchy?

帅比萌擦擦* 提交于 2019-12-02 21:36:21
I'm new to server side web development and recently I've been reading a lot about implementing RESTful API's. One aspect of REST API's that I'm still stuck on is how to go about structuring the URI hierarchy that identifies resources that the client can interact with. Specifically I'm stuck on deciding how detailed to make the hierarchy and what to do in the case of resources being composed of other resource types. Here's an example that hopefully will show what I mean. Imagine we have a web service that lets users buy products from other users. So in this simple case, there are two top level

RESTful - What should a DELETE response body contain

烂漫一生 提交于 2019-12-02 20:01:46
Let's say I have an API where you can get users: GET /RESTAPI/user/ And you can delete users by: DELETE /RESTAPI/user/123 What is the RESTful convention on what the DELETE's response body should contain? I expected it should be the new list of all users which now doesn't contain the user with id 123 anymore. Googling around didn't get me any satisfying answers. I only found opinions on how to do that, but isn't there a strict definition of RESTful Services ? This is NOT a duplicate of What should a RESTful API POST/DELETE return in the body? and What REST PUT/POST/DELETE calls should return by

RESTful API URI Design

岁酱吖の 提交于 2019-12-02 17:42:45
I'm looking for some direction in regards to the URI design for a RESTful API. I'm going to have several nested linked resources and have currently designed my URI's similar to this post: Hierarchical RESTful URL design The following example isn't what I'm building but I think illustrates my situation well. (Assume that a show can only belong to one network). /networks [GET,POST] /networks/{network_id} [GET,PUT] /networks/{network_id}/shows [GET,POST] /networks/{network_id}/shows/{show_id} [GET,PUT] /networks/{network_id}/shows/{show_id}/episodes [GET,POST] /networks/{network_id}/shows/{show