#1993 JS - Altering the fan scheme http url

SlimerDude Mon 6 Aug 2012

Are there any hooks into the fan scheme url generation (for JavaScript)? i.e.

`fan://podname/res/image/dude.png`.get 

when resolved is converted into http://mypod/res/image/dude.png. I want to alter the URL to automatically include the associated pod version, e.g. http://mypod/1.2.3/res/image/dude.png. This way, when I deploy a new version of the pod, the URLs will automatically update, ensuring clients don't use older, out of date, cached versions. (This becomes more important when downloading javascript files.)

I know there's the sys.uriPodBase environment variable, but that's a global hook changing ALL the urls, I just want to change those urls bound to a pod. i.e. if podA gets updated, only podA resource urls change, leaving podB urls the same.

Thinking ahead, this would mean you could have a web pod server that serves up all pod resources in a given Fanr repository, not just from what's installed in the given environment. That could be handy!

brian Mon 6 Aug 2012

I don't think we want to change syntax of a well-known scheme like "fan://". Rather I think we'd want to add a new scheme. Adding new schemes is pretty straight forward in JVM using index props. Not sure how it gets plugged into JS

SlimerDude Mon 6 Aug 2012

I think you misunderstand... I was explaining my use case. I wasn't suggesting a change the behaviour of the fan:// scheme.

I could add a new scheme, but then I'd have to change all the urls in all my apps. I'd then have to make the new scheme default to fan:// in java and do something else in JS.

Alternatively, there's code somewhere that converts fan:// into http:// and I was just wondering if there were any call back hooks around that code to let me have a say in what http:// url gets generated.

brian Mon 6 Aug 2012

So you are saying that your fan:// URIs all use the normal syntax. You just want a hook when they are being resolved? If so, then why not put that hook into server using your own WebMod?

SlimerDude Mon 6 Aug 2012

It's on the client side when the fan:// url is resolved in to a http:// url.

Of course, I would then have to handle how / what gets served on the server (via a WebMod if using Fantom).

andy Tue 7 Aug 2012

Not really any requirement to use fan scheme - just convenience. Just as simple to handle on your end - which is what I would do in your case.

Login or Signup to reply.