Tag Info

Hot answers tagged

16

The protocol exists, there is a clear answer for what to do. This isn't anything super secret - it is an "in-house web application for my university's department." Do the thing that confuses your users and applications the least in the way that allows for proper expansion in a way that is also consistent. Consider the proposed page flow: User goes to ...


7

Don't be consumed by UX in these situations. A 403 or 404 code is extremely useful information to have. Some users may not understand it, but translating it into something else in a misguided attempt to make it user friendly is a bad idea. You need to show any 400 or 500 level error to users so the users can report them to you. If a user gets a 404, that's ...


7

Is there a technique for unit testing both components in one run? That would actually be the opposite of unit testing - unit testing, especially in TDD style, means to test your components in isolation. Thus the answer is yes, "run separate test suites for the JS and PHP sections", otherwise it is not unit testing and not TDD. Of course, automated ...


6

You might generate the error page (for 403: Forbidden HTTP error code). That error page might contain links to appropriate (context dependent) pages. I'm doing a similar thing on http://gcc-melt.org/ using my lev404cgi CGI program (free software GPL3+ licensed). Try opening http://gcc-melt.org/docu or http://gcc-melt.org/foobar; these are 404: Not found ...


5

None of the above, actually. It is the responsibility of your controller to write the data to file, although I'd recommend writing a specific class for that and just having the controller use that class. It is not a view because views in MVC are strictly about rendering data in the UI. The data itself should probably be put into a model and that model ...


3

Consider that returning a 403 may itself be leaking privileged information, i.e. how many total projects exist and how frequently they are being added. I agree with the suggestions to redirect the user to a helpful list of what they are allowed to see. I would not reveal that they have located something that they are not allowed to access. This may seem ...


3

This is a classic API design dilemma, regardless of whether it's provided by a web service, or by linking a library, or by just being part of a code base that gets built along with everything else. It boils down to whether you prefer many functions that each do one specific thing, or whether you have fewer, more parameterized functions. Since web calls are ...


2

On Linux and POSIX systems, you'll better lock the file using e.g. advisory locking like flock(2) or lockf(3) (and if your application is multithreaded, you'll better use some way -e.g. mutexes- to ensure that only at most one single thread is accessing the file). You might have one (single and well defined) goroutine reading on some go channel for that ...


2

tl;dr - I second Basile's solution, and don't believe you've thought through the implications of your preferred 303 redirect. 1.) The server redirects the user to /projects/2 (their previously visited page, which would of course always be a valid one) with a helpful notification at the top such as "Sorry, but you do not have permission to access XXXX" ...


2

It sounds like your use case is: When the user indicates they want to do XYZ, the browser sends a request to the server, which sends back a nice friendly reply page saying the user isn't allowed to do that. In that case, from the HTTP server's point of view, the request isn't forbidden. You can have the server reply with status 200 without ...


2

The important thing is to distinguish between TDD and ATDD. The AT there stands for "acceptance tests", and this refers to development where you first start with an acceptance test, which is likely to test the entire stack. This is also sometimes called "outside-in test driven development". When people talk about TDD, the "T" there probably refers ...


1

I'm trying to determine when a web application should query a database for related data that may or may not be used in the current request. For such general questions it's hard to give a general answer. You have to consider two points: convenience and performance. Many things, which seem at first sight convenient are at hindsight performancekillers. ...


1

In your DAO layer, you should have a way to mark a relationship as required or optional (terms may vary based on whatever framework you use). Required relationships mean that if A links to B and I query A, the web service must return B as well. Use this for data where the two objects are always used together. Optional relationships mean that if A links to ...


1

I suggest that you 1) learn what other REST APIs do, and 2) consider OData I love Odata because it supports every scenario you listed in one single API call. I'm biased though, because in C# you can implement an Odata server in just a few lines of code if you use the Entity Framework. There's also client side libraries that can format OData URLs. Let me ...


1

I have done such things as REST, which, as you say, doesn't solve all problems, though at least a few of them possibly. Basically search features I have implemented using URL params instead having a single URL for each of them. So your get_user_by_email would just be /user?email=joe.doe@something.net Similar you can handle the returned data for things ...


1

Is it easy to call a SOAP web service from an Angular service? No it is usually not possible because browsers are limited to making requests to the same domain as the webpage is hosted unless you apply some CORS. I have never seen anyone try and call SOAP from javascript. If we ignore the security limitations of the browser any credentials for the ...


1

Here is the design that I work with. I found it useful on two larger projects I built and haven't hit any road blocks so far. Required Libraries for this Setup Angular Angular UI Router Folder Structure your-project/ apps/ global.html app1/ index.html app1.module.js app1.js parts/ foo.js foo.html ...



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