As I'm creating my web site, I'm getting a lot of experience with the Fan web stack. So far, I'm liking it. Thinking about objects in terms of Uris and Objs is much more fun than what I've had to work with in the past.
I am keeping a list of every little wrinkle I bump into with Fan, so expect it all to trickle down to here eventually. Last night, my issue was with how Wisp maps URLs to Fan Uris. Originally with my site, I wanted the URLs to look like:
http://example.com/{username}/{postId}
The problem is mounted UriSpaces can't accomplish this. The mount method requires a custom UriSpace be mounted to a branch. What I really wanted to do was "point" the FindResourceStep to that branch, so that URLs like /tactics/1 would map to the Fan URI fan:/mywebsite/tactics/1 (as opposted to fan:/tactics/1).
Additionally, the idea of making the entire Fan urispace public is uncomfortable for me. I know that it requires that you register a weblet for each type you want to serve, but I had one of those nagging feelings you sometimes get when thinking about security. I'd rather have the Wisp server restricted to a sandbox in the Fan urispace. That way, in case some dork (probably me) messes up and makes a view for sys::Service or sys::Obj, there is no chance of anyone getting to peek at the contents of /sys/service/sql::SqlService or my other registered services.
It was easy enough to roll out a 5 line custom solution. I subclassed FindResourceStep so it takes an optional "base" Uri. When a resource uri is looked up, it calls the parent class's find() method with a modified Uri relative to base. I thought I'd share this solution, since it would be nice to have in the distribution.
One last thing. I found it strangely difficult to concatenate an absolute Uri to another. Wisp passes an absolute Uri such as /tactics/1, and I wanted to make that into /mywebsite/tactics/1, but I couldn't do a simple base + uri, because the absolute-ness of the latter overwrote the former. I had to cast uri to a Str and chop off the leading slash to concat them. Can we either change the semantics to facilitate this or add a plusRelTo(base, uri) method which handles the case where uri might be absolute?
Thanks again for all your hard work on Fan. It's really a pleasure to work with!
brianTue 20 Oct 2009
I completely agree that FindResourceStep is probably too simplistic for most web-apps.
I am open to ideas to how to enhance the existing functionality. Hopefully soon we'll have a web application framework really designed for Fan. Originally our plan was to build this out as we built SkyFoundry. But it turns out that our FWT-JavaScript strategy has totally negated the need for hardly any server side code. So server side web apps have been somewhat neglected by us in favor of FWT. Andy probably has some comments on this subject too I'm sure.
andyTue 20 Oct 2009
Managing Uri's certainly isn't the simplest thing to do right now. But I think that has more to do with Fan not forcing any Uri structure (a la Ruby on Rails). Since its completely open-ended we push that complexity onto the developer right now. I think for the web pod, this is correct, to maintain a clean integration point to web servers.
What's really missing is a turn-key framework like Rails built on top of the web pod, that does layout conventions for how to manage Uris, files, security, etc. Originally, thats what our SkyFoundry work was going to produce, but as Brian said, we have moved almost exclusively to a JavaScript-UI.
I would love to see a "Fan on Rails" if anyone was so inclined.
brianTue 20 Oct 2009
Not sure there is a specific action item here yet.
But I would recommend for now, that the best way to handle it is to create a custom FindResourceStep (which is actually pretty easy).
For Bespin, we just created a whole custom pipeline that does exactly what we want - the whole thing is less than a 100 lines of code.
tacticsWed 21 Oct 2009
Like I said, I wrote a custom solution in a grant total of 5 lines that does exactly what I want. I just wanted to record this need in the forums =-)
tactics Mon 19 Oct 2009
As I'm creating my web site, I'm getting a lot of experience with the Fan web stack. So far, I'm liking it. Thinking about objects in terms of Uris and Objs is much more fun than what I've had to work with in the past.
I am keeping a list of every little wrinkle I bump into with Fan, so expect it all to trickle down to here eventually. Last night, my issue was with how Wisp maps URLs to Fan
Uri
s. Originally with my site, I wanted the URLs to look like:http://example.com/{username}/{postId}
The problem is mounted
UriSpace
s can't accomplish this. Themount
method requires a customUriSpace
be mounted to a branch. What I really wanted to do was "point" the FindResourceStep to that branch, so that URLs like/tactics/1
would map to the Fan URIfan:/mywebsite/tactics/1
(as opposted tofan:/tactics/1
).Additionally, the idea of making the entire Fan urispace public is uncomfortable for me. I know that it requires that you register a weblet for each type you want to serve, but I had one of those nagging feelings you sometimes get when thinking about security. I'd rather have the Wisp server restricted to a sandbox in the Fan urispace. That way, in case some dork (probably me) messes up and makes a view for
sys::Service
orsys::Obj
, there is no chance of anyone getting to peek at the contents of/sys/service/sql::SqlService
or my other registered services.It was easy enough to roll out a 5 line custom solution. I subclassed
FindResourceStep
so it takes an optional "base"Uri
. When a resourceuri
is looked up, it calls the parent class'sfind()
method with a modifiedUri
relative tobase
. I thought I'd share this solution, since it would be nice to have in the distribution.One last thing. I found it strangely difficult to concatenate an absolute Uri to another. Wisp passes an absolute
Uri
such as/tactics/1
, and I wanted to make that into/mywebsite/tactics/1
, but I couldn't do a simplebase + uri
, because the absolute-ness of the latter overwrote the former. I had to cast uri to aStr
and chop off the leading slash to concat them. Can we either change the semantics to facilitate this or add aplusRelTo(base, uri)
method which handles the case where uri might be absolute?Thanks again for all your hard work on Fan. It's really a pleasure to work with!
brian Tue 20 Oct 2009
I completely agree that FindResourceStep is probably too simplistic for most web-apps.
I am open to ideas to how to enhance the existing functionality. Hopefully soon we'll have a web application framework really designed for Fan. Originally our plan was to build this out as we built SkyFoundry. But it turns out that our FWT-JavaScript strategy has totally negated the need for hardly any server side code. So server side web apps have been somewhat neglected by us in favor of FWT. Andy probably has some comments on this subject too I'm sure.
andy Tue 20 Oct 2009
Managing Uri's certainly isn't the simplest thing to do right now. But I think that has more to do with Fan not forcing any Uri structure (a la Ruby on Rails). Since its completely open-ended we push that complexity onto the developer right now. I think for the
web
pod, this is correct, to maintain a clean integration point to web servers.What's really missing is a turn-key framework like Rails built on top of the
web
pod, that does layout conventions for how to manage Uris, files, security, etc. Originally, thats what our SkyFoundry work was going to produce, but as Brian said, we have moved almost exclusively to a JavaScript-UI.I would love to see a "Fan on Rails" if anyone was so inclined.
brian Tue 20 Oct 2009
Not sure there is a specific action item here yet.
But I would recommend for now, that the best way to handle it is to create a custom FindResourceStep (which is actually pretty easy).
For Bespin, we just created a whole custom pipeline that does exactly what we want - the whole thing is less than a 100 lines of code.
tactics Wed 21 Oct 2009
Like I said, I wrote a custom solution in a grant total of 5 lines that does exactly what I want. I just wanted to record this need in the forums =-)