const mixinafBedSheet::PodHandler
afBedSheet::PodHandler
(Service) - A Route Handler that maps URLs to file resources inside pods.
To access a pod resource use URLs in the format:
/<baseUrl>/<podName>/<fileName>
By default the base url is /pods/
which means you should always be able to access the flux icon.
/pods/icons/x256/flux.png
Change the base url in the application defaults:
@Contribute { serviceType=ApplicationDefaults# } static Void contributeAppDefaults(Configuration conf) { conf[BedSheetConfigIds.podHandlerBaseUrl] = `/some/other/url/` }
Set the base url to null
to disable the serving of pod resources.
Because pods may contain sensitive data, the entire contents of all the pods are NOT available by default. Oh no! PodHandler
has a whitelist of Regexes that specify which pod files are allowed to be served. If a pod resource doesn't match a regex, it doesn't get served.
By default only a handful of files with common web extensions are allowed. These include:
. web files: .css .htm .html .js image files: .bmp .gif .ico .jpg .png web font files: .eot .ttf .woff other files: .txt
To add or remove whitelist regexs, contribute to PodHandler
:
@Contribute { serviceType=PodHandler# } static Void contributePodHandler(Configuration conf) { conf.remove(".txt") // prevent .txt files from being served conf["acmePodFiles"] = "^fan://acme/.*$" // serve all files from the acme pod }
- baseUrl
abstract Uri? baseUrl()
The local URL under which pod resources are served.
Set by BedSheetConfigIds.podHandlerBaseUrl, defaults to
/pods/
.- fromLocalUrl
abstract FileAsset fromLocalUrl(Uri localUrl)
Given a local URL (a simple URL relative to the WebMod), this returns a corresponding (cached)
FileAsset
. ThrowsArgErr
if the URL is not mapped or does not exist.- fromPodResource
abstract FileAsset fromPodResource(Uri podResource)
Given a pod resource file, this returns a corresponding (cached)
FileAsset
. The URI must adhere to thefan://<pod>/<file>
scheme notation. ThrowsArgErr
if the URL is not mapped or does not exist.- serviceRoute
abstract FileAsset? serviceRoute(Uri remainingUrl)
The (boring) Route handler method. Returns a
FileAsset
as mapped from the HTTP request URL or null if not found.