Tag Info

New answers tagged

0

You should have very specific, semantic requests. For instance: You want to pull information about a specific owner example.com/owner/123 You want to pull information about a specific owner's assets example.com/owner/123/assets Now you want to pull all assets that belong to owner 123 example.com/ownerAndAssets/123 Or you want to pull a specific ...


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 ...


0

OK in PHP "SESSION" is an illusion. Every interaction between the browser and the web server is a single atomic transaction unrelated to any other interaction. The "SESSION"mechanism gives the illusion of a "connection" by passing a cookie to and from the browser and storing some variables locally at the server. You can end a SESSION the the ...


0

403, 404 and 401 which you didn't mention have specific meanings. 403 (forbidden) doesn't mean that this particular user isn't allowed to access the resource, but that nobody is. It has nothing to do with that particular user, and there is nothing the user can do to be allowed access. 401 (unauthorized) means that the user wasn't authorized to access the ...


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 ...


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 ...


0

I'm going to give a second answer, because looking back at what you wrote I think you might be asking a more basic question than I thought, one that deserves a very simple answer: Is it okay to return the “wrong” HTTP status code in order to show a more user-friendly error page? Yes. The HTTP specification does not say that web applications (such as ...


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" ...


12

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 ...


6

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 ...


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 ...


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 ...


0

In a slight variation of JDT's answer...if I'm understanding all of it correctly, this is how I view it (pardon the pun): View/Controller: Both part of the presentation concern. The controller acts as the intermediary between the view and the model, affecting changes to the model (unless you have binding to the model from the view) and reflecting model ...


0

I had the same problem but my situation was a little bit different, let me explain. In my project I had to use files for two purposes: Store data (database) Track errors (log file) So my model was dedicated to the interaction with files used as database and i created some helpers (I was using Codeigniter) to write log files. In this way i could invoke ...


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 ...


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 ...


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 ...


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 ...


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 ...


3

My reading of the GPL is that it does not apply to this kind of scenario, where a UI (the web browser) accesses the program over a network. In fact, they state as much in the license: To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with ...


1

You may want to check out Docker (like a VM image) as a way to "containerize" your deployment. That way any OS that is able to run the docker module can take your containerized content and use it the same way you would. There are numerous existing Docker modules that you could even start with which will contain php, database images etc. The only issue would ...


3

Don't write GUI tests to match the GUI. Write acceptance tests that match requirements You could write your tests like this: Given I enter "user" into the username field and "pass" into the password field And I click the "Login" button When I click the Find User button And I enter "foo" into the username field And I click "Search" Then I should see a ...


0

You can utilize a cloud hosting provider like Microsoft Azure, which is in no way limited to Windows VM's, they have plenty of Unix/Linux images as well as give you the ability to upload your own VM's. Amazon has similar features. You can create virtual networks, web farms, create vpn connections, etc, manage multiple subscriptions and add users at ...


1

Consider using a queue, where each method access resulting an entry, and use a timer job queue length reaching certain threshold to flush the queue into the database.


2

You can set a threshold. For instance, you can store that someone visited at 14:00PM, and then audit if the difference between then and the current time is more than 30 minutes, so you have 2 updates per hour at most. If you have a stateful service, another approach would be to store the time of each request in memory (default session driver, Redis, ...



Top 50 recent answers are included