#2160 How do i configure afBedSheet to return css file

Bob147 Tue 2 Jul 2013

Hi Steve,

How would I setup afBedSheet to return the content of a .css (or a .js) file that is being requested by the browser as it process an html file? I have returned the html file using the normal afBedSheet routing using TextResult.fromHtml((uri.get as File).readAllStr but I am afraid that I cannot work out from the current level of documentation how to setup the routing to return the referenced css and js files.

I hope this makes sense!

Regards Bob

SlimerDude Tue 2 Jul 2013

Hi Bob,

To serve up static files (.html, .js, .css or otherwise), use the FileHandler service. In your AppModule:

@Contribute { serviceType=FileHandler# }
static Void contributeFileHandler(Configuration config) {

   // tell FileHandler where to look for files under '/pub/'
   // e.g. `/pub/css/mystyle.css` => `file:etc/web/css/mystyle.css`
  config[`/pub/`] = `etc/web/`.toFile
}

There's a mini app used in the tests afBedSheet/test/app/ which may be useful as an example until the docs get better.

Hope this helps,

Steve.

Bob147 Tue 2 Jul 2013

Thanks Steve,

That worked nicely! I can now serve the html and its internally referenced .css file and see the rendering I expected. Have you finished the Tales integration yet ;-) It looks as though your framework is perfect for the app I am going to be working on.

Now, if only Wisp supported websockets...

Bob

Login or Signup to reply.