restful-architecture

Named restful routes in Laravel 4

狂风中的少年 提交于 2019-12-02 21:27:32
So, I've been able to get restful controllers working with Route::controller('users','UserController'); class UserController extends BaseController { public function getAccount(){} } and so /users/account works. However if I try to do something like Route::any('account',array('as' => 'account','uses' => 'UserController@account')); and go to /account , it doesn't work ( NotFoundHTTPException ). Is there a way to use named routes and restful controllers in conjunction? I like how the restful system breaks up requests, and how named routes encapsulate the URI's and decouple them from the function

Way to specify resource's fields list in RESTful API request

一世执手 提交于 2019-12-02 20:07:47
I have RESTful API within a web-service with some kind of resources like users, posts and so on. When I make request for list of posts (GET /posts), I want to retrieve array of posts only with reduced part of data for each post (i.e. subject, author name). When I make request for concrete post (GET /posts/42) I want to retrieve full list of post object fields, including big post body, additional info about likes count, comments count. I suppose it is exists many ways to solve this problem. In my mind, 3 most obvious are: Explicitly specify fields lits on every request (/posts?fileds=subject

URL design restful api

怎甘沉沦 提交于 2019-12-02 19:49:25
问题 Lets assume that i want to build a restful api which should add items to a shoppingcart. I think the most straight forward way would be like this: POST /shoppingcarts/{shoppingCartId}/items - to generate an itemId PUT /shoppingcarts/{shoppingCartId}/items/{itemId} Now it is possible that a shoppingcart does not exist when i want to add an item to it. There is also a requirement that the client must not create a shopping cart. If the client adds an item and a shoppingcart does not exist then

Should a RESTful GET response return a resource's ID?

依然范特西╮ 提交于 2019-12-02 18:10:58
A number of the developers here are having a friendly (some would say religious) discussion about whether a GET request from a RESTful API should return the ID of the requested resource . Let's assume the following GET request: http://my.api.com/rest/users/23 This currently returns: {"name": "Jim", "age": 40, "favoriteColor": "blue"} Note that "id" is missing from the result set. There are basically 4 camps battling with this issue. CAMP #1: When callers make the GET request, they already know the ID. Therefore, the result set should not include the ID. If callers need this data to enable UI

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

How to combine websockets and http to create a REST API that keeps data up to date? [closed]

旧巷老猫 提交于 2019-12-02 17:25:46
I am thinking about buildning a REST API with both websockets and http where I use websockets to tell the client that new data is available or provide the new data to the client directly. Here are some different ideas of how it could work: ws = websocket Idea A: David get all users with GET /users Jacob add a user with POST /users A ws message is sent to all clients with info that a new user exist David recive a message by ws and calls GET /users Idea B: David get all users with GET /users David register to get ws updates when a change is done to /users Jacob add a user with POST /users The

Different REST resource content based on user viewing privileges

北城余情 提交于 2019-12-02 16:44:14
I want to provide different answers to the same question for different users, based on the access rights. I read this question: Excluding private data in RESTful response But I don't agree with the accepted answer, which states that you should provide both /people.xml and /unauthenticated/people.xml , since my understanding of REST is that a particular resource should live in a particular location, not several depending on how much of its information you're interested in. The system I'm designing is even more complicated than that one. Let's say that a user has created a number of circles of

Laravel 4 as RESTful backend for AngularJS

不羁岁月 提交于 2019-12-02 14:44:35
I am trying to build a web application which should use Laravel as a RESTful backend API and AngularJS on client side. I read all the other post on Stackoverflow about the issue, but no one is definitely answering my doubts, at least, I did not find a definitive source example. For instance... Should I develop two completely distinct applications, a backend one with Laravel and another, purely client, with AngularJS? But in this case: how to handle them through a single domain (or virtual host)? Or should I create AngularJS templates inside Laravel, in the "views" folder and from them call

Questions About Consuming Your Own API with OAuth

拥有回忆 提交于 2019-12-02 14:08:39
I'm building a RESTful API for a project I'm working on and I'd like to make the main application consume the API because: It will result in having one set of code to maintain Should we decide to expose the API for 3rd party devs it will already be done It opens up the possibility to make mobile applications that consume it I really want to learn how to do it The API will be hosted on a subdomain https://api.example.com and the main web application will be hosted at the root domain https://example.com . Conceptually I understand how everything works, but my main question is how the

Updating RESTful resources against aggregate roots only

不想你离开。 提交于 2019-12-02 07:54:11
问题 Usually I architect RESTful APIs using the following resource URI scheme: POST /products PATCH /products/{id} GET /products GET /products/{id} DELETE /products/{id} Products may also contain product features . When I want to get some product's features, I would perform a GET /products/{id}/features . BTW, if I want to add new features to a given product, usually I don't provide a resource URI like this: PATCH /products/{id}/features but I consider that features are part of a given product,