Let's say I configure redstone as follows
@app.Route("/raw/user/:id", methods: const [app.GET])
getRawUser(int id) => json_about_user_id;
When I run the server and go to /raw/user/10
I get raw json data in a form of a string.
Now I would like to be able to go to, say, /user/10
and get a nice representation of this json I get from /raw/user/10
.
Solutions that come to my mind are as follows:
- First
- create
web/user/user.html
andweb/user/user.dart
, configure the latter to run whenindex.html
is accessed - in
user.dart
monitor query parameters (user.dart?id=10
), make appropriate requests and present everything inuser.html
, i.e.
- create
var uri = Uri.parse( window.location.href );
String id = uri.queryParameters['id'];
new HttpRequest().getString(new Uri.http(SERVER,'/raw/user/${id}').toString() ).then( presentation )
A downside of this solution is that I do not achieve /user/10
-like urls at all.
Another way is to additionally configure redstone as follows:
@app.Route("/user/:id", methods: const [app.GET]) getUser(int id) => app.redirect('/person/index.html?id=${id}');
in this case at least urls like "/user/10" are allowed, but this simply does not work.
How would I do that correctly? Example of a web app on redstone's git is, to my mind, cryptic and involved.
I am not sure whether this have to be explained with connection to redstone or dart only, but I cannot find anything related.