Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL sharing in web app

Here's the problem I need to solve. I have a web application that basically allows user to query some server datasource and see the query results - a kind of reporting application. The query can be created by user by specifying values for a number of predefined parameter types. Suppose A1....AN is a list of possible parameters, so the query will look like *A1="some_value"&A2="some_other_value"&...&AN="whatever"*. I need a way to share these queries between application users, a kind of "bookmarking" functionality. I can foresee two different approaches that can be used to solve this problem:

  1. Incorporate query into URL. So I would have something like *http://www.myapp.com/q=possibly_very_very_very_long_string* as an URL that can be shared between people. Personally I don't like this approach. The long URL can be a mess. Sending it via e-mail or any other transport, copy/pasting it etc will definitely lead to poor user experience

  2. Use server-side storage for mapping those long "urls" to some more user-friendly ones. Trivial example would be to something like: http://www.myapp.com/q=12345 where 12345 would be an ID of that query in application database. This approach looks more attractive to me.

What are your thoughts on the above? Maybe I'm missing something?

like image 500
andrew.z Avatar asked Oct 24 '22 14:10

andrew.z


2 Answers

Your second suggestion sounds like the best as far as I can see.

What you might consider is to restructure your URL. Maybe you could drop the regular URL format, as long as you know what to expect from each parameter. If the length of the parameter are constant you might even pass all as just one long parameter.

like image 186
Audun Larsen Avatar answered Jan 02 '23 19:01

Audun Larsen


I would also prefer your second option. Another option is to use a Google URL shortener or similar.

like image 38
PedroC Avatar answered Jan 02 '23 19:01

PedroC