Closed danschultz closed 8 years ago
What are you trying to accomplish? An Interceptor or route decorator plugin might what you need.
I'm trying to write an isomorphic Dart app using React. I'd like Redstone to respond to any path, and pass the path into a React component which will handle the routing.
How about this?
@app.Route ('*', matchSubPaths: true)
anyPath () => app.request.url;
Matches any route and you can the path from the url
.
That works, but I also need access to the path in order to pass it into my server-side React component which is handling the routing. I tried the following, but I get a 404:
@app.Route(':path*', matchSubPaths: true)
anyPath(String path) => app.request.url;
Is this enough?
@app.Route ('*', matchSubPaths: true)
anyPath()
{
var path = app.request.url;
//Do something with path
}
The url
IS the path.
The following example works fine in v0.6.0-beta.1
import 'redstone/redstone.dart';
@Route(":path*", responseType: "text/html")
String all(String path) => path;
Sorry @cgarciae, I overlooked app.request.url
. I'll give that and v0.6.0 beta a try.
I'm trying to define a route that matches everything, but also passes the path as a param to its annotated function. For example:
path = ""
path = "foo"
path = "foo/bar"
I tried the following, and it works for sub-paths, but fails on root
/
.Is this possible with Redstone?