Tag Info

Hot answers tagged

6

Yes, your understanding is correct. Although, some REST services can be accessed directly, without passing by the server 2. Getting a response is a matter of milliseconds, especially when data centers are close to each other geographically (because indeed, speed of light matters). If we are talking about small web apps, the REST service and the app may be ...


5

The answer discusses in general the aspect of sending large data over HTTP using REST. Make sure you also read the answer by Robert Jack Will which is more specific and suggests a way which makes it possible to avoid sending large data in the first place. REST has nothing to do with XML: the format of the data, would it be JSON, XML, plain text or ...


5

REST doesn't have anything to say about which controller services which URL. From a purely hierarchical perspective, your first example makes more sense because the first (most general) level in the URL is being handled by its respective controller. i.e. /theaters/:id/movies -- belongs in the Theaters controller, and /movies/:id/theaters -- belongs in ...


3

No one said you can't make a URI for /api/foos/?page=1. A container is not the same as the things it contains; a list of foos is a different resource from the individual foos.


2

How is the enquiry_id in the "client URL" (that points to a partner's site) generated? If it always matches the enquiry ID that is being used for the URLs you control, then you can simply require that the partners provide a URL template for you to use when setting up an integration with their system. When you generate the email, use the provided URL template ...


2

There is nothing wrong in doing that. Imagine a list of messages which are shown to some groups of users only: one person would see a specific response, another one will see more messages; an administrator will probably see every possible message; a guest won't see anything. You should be careful though. If the form of the response changes radically and ...


2

It seems the most straightforward method is just returning a XML or JSON, with the numbers and status. Per your description, I imagine a structure like this would suffice: { requestDate: '2015-02-05 12:32' results: [{ number: 1, status: 'forwarded', }, { number: 2, status: 'forwarded', }, { number: 3, ...


2

When it comes to API authentication, those are the three most used models (in random order): Credentials are sent with every response. Credentials are sent once to generate an access key. The access key is then sent with every request. Credentials are sent once, and then a session (relying on cookies) is used to avoid repetitive authentication. Since one ...


2

If an owner can grant access to other users, then it is called Discretionary Access Control (DAC): discretionary access control (DAC) is a type of access control defined <...> "as a means of restricting access to objects based on the identity of subjects and/or groups to which they belong. <...> The term DAC is commonly used in contexts that ...


2

The first solution has a benefit of avoiding data duplication. The request plainly means: Hello, I'm John. Give me the list of my friends. If possible, I would even shorten it to GET /api/friends. On the other hand, if you expect to be able to access friends of other users, the second solution appears the good one. The request means: Hello, I'm ...


2

As for if and how to use HTTP for the data transfer, I completely agree with MainMa's answer. However, independently of the size of the data, the process which you describe doesn't sound a like a typical application for Rest. One of the main ideas of Rest is having named resources like mycompany.com/claims/customer/{number}/claim/{number} which can be ...


2

Should REST or the database be responsible for referential integrity? Both: DB should have proper constraints. API should have validation rules which reflect those constraints (e.g. "role_id cannot be null on user object"), check those, and provide meaningful error messages when they are violated. Is it bad practice to have foreign keys ...


1

Yes, Rest API is very powerful for your scenario Expose all of your services through API endpoints. Always consider doing following when building Apis Authentication - have an strong authentication system in your API, like token based authentication ( Json web token) Authorization - every single API need to be access controlled, have the user ...


1

There are a few things that make this API not very RESTful: REST API URLs identify resources, not actions. First, actions should not be part of the URL path. The actions are the different HTTP methods. Instead of doing something like GET /api/person/findByEmail/ssmith@acmeco.com, you should remove findByEmail and use query parameters to convey that you're ...


1

If JAX-RS is not a requirement, then I'd suggest looking at Restlet. It uses conveyor architecture, so nesting resources into other resources is not a problem - see hierarchical URIs. When integrating with Spring, you typically define root SpringBeanRouter, in which you put actual resources, in each of which you can put another routers, and so on. You can ...


1

There's HTML5 local storage, which allows you to keep data without it contaminating the HTTP requests you make. It's intended for pretty much exactly this use case: complex Javascript applications that want to store persistent information locally. http://www.w3.org/TR/webstorage/ Note that REST doesn't mean banning all state from the server, sometimes you ...


1

An application design like this might be advantageous if you take the broader infrastructure into account. Possibly, your Core project serves more than one other project and combines common business logic across your application infrastructure. Then it might make sense to have it as a separate web application rather than compiled into the same application. ...


1

Within the request and response you send it does not immediately make sense, but I'll give a simpler example. Imagine we'll have a pizza-ordering system, that allows us to order either pizza's (with extra toppings) or soft-drinks (potentially super-sized). To implement our service, we could format it like this: { drinks: [{ brand: 'pipsi', size: ...


1

I think you may have a user-process to implementation mismatch here. First: will a user honestly want to perform multiple changes to a file simultaneously? A rename (which may or may not include a change of path?), change of ownership, and perhaps change of file contents (for sake of argument) seem like separate actions. Lets take the case where the answer ...


1

Rest Api's must be hypertext driven ! As you would click from one link to another in a standard html page. An URL is a unique identifier to a resource. Having an url representing more than one resource is in total disacordance with ReST. With your example, the following url : /api/users/:userId should have a link in its response to the :userId friends ...


1

SOAP is a standardized communications protocol. A SOAP request: POST /InStock HTTP/1.1 Host: www.example.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body ...


1

To echo what MainMan said, there are two different concepts at play here, REST and microservices. Your diagram is a micro-service set up. You can do this with RESTful architecture, or with any other architecture. While micro-services and REST are often used together they are not the same thing. REST is a way of thinking about communication between clients ...


1

Another alternative (using HATEOS). This is simple, mostly in practice you add a links tag in the json depending on your use of hateos. http://api.example.com/games/1: { "id": 1, "title": "Game A", "publisher": "Publisher ABC", "developer": "Developer DEF", "releaseDate": "2015-01-01", "platforms": [ {"_self": ...


1

As I currently understand HATEOAS is basically all about sending together with each response links with information about what to do next HATEOAS is a lot more than just links. It is "hyper media" as the engine of application state. What is missed in your description is the content type, the formal definition of the hyper media that is passed between ...


1

You don't have to build a dynamically generated interface. Though it could be nice it's not required. If you cannot build a dynamic interface just use the links and you are done. Disadvantage is that you are again hard linked to the backend and will crash if something changes. Using the dynamic layout can be quite simple btw: links.forEach(function(link) { ...


1

the app we are building won't simply look at the links and then by itself render the correct UI and make the right ajax calls In fact, this is exactly what HATEOAS will give the UI. Not what is possible, but when it is possible. A formal HATEOAS like HAL, as the question states, gives links that indicate what is possible. But when those links show ...


1

What other really useful Django features would I lose? "Lose" is probably the wrong way to think about it. Never use and just take up space is probably more accurate. It could be argued that Django is too big a framework for what you are describing. Is there any particular reason why you have to use Django? A micro-framework like Flask might fit the ...


1

You should design your backend around the resources you are exposing from the backend. These do not have to match up exactly to your model (the exposed resources and the internal model are two separate things), but often you will have a lot of overlap. For example you might have a "user" model object and a "user" resource exposed by the server. A ...


1

If each client you intend to service requires different output from your back end. Then write your back-end in a way where is can serve each type. Do some abstraction. Ask yourself, what things will all clients need the same way, and what things will each client need in a specific different way. Put all the stuff that is the same for all clients together, ...


1

Whenever you define a non-CRUD operation you will be in trouble to find a HTTP method, which describes the same thing. This can be solved by defining a new resource. So REST resources cannot be mapped 1:1 to entities. That's the problem in your case. Imho you need a domain model which is working with the entities and you need a delivery method, which ...



Only top voted, non community-wiki answers of a minimum length are eligible