abstract const classafBedSheet::ClientAsset
sys::Obj afBedSheet::Asset afBedSheet::ClientAsset
(Response Object) - An asset that is uniquely identified by a client URL.
A ClientAsset corresponds to a client URL that may be used by clients (e.g. internet browsers) to retrieve the asset.
Generally ClientAssets are acquired from the FileHander and PodHander services and used to embed client URLs in web pages.
urlStr := fileHandler.fromLocalUrl(`/images/fanny.jpg`).clientUrl.encode
The URLs generated by ClientAssets may be automatically transformed by asset caching strategies such as Cold Feet. As such, ClientAsset instances are cached and automatically updated should the underlying asset be modified. To prevent needless polling of the file system, assets are checked for modification every 2 minutes in production or 2 seconds otherwise.
Custom Client Assets
If you want to serve up assets from a database or other source, subclass ClientAsset to create your own custom implementation. Custom ClientAsset instances should created by a ClientAssetProducer and contributed to the ClientAssetProducers service. This ensures your custom assets will automatically adopt any asset caching strategy set by Cold Feet.
- clientUrl
virtual Uri? clientUrl()The URL that clients (e.g. web browsers) should use to access the asset resource. The
clientUrlcontains any extraWebModpath segments required to reach theBedSheet WebMod. It also contains path segments as provided by any asset caching strategies, such as Cold Feet.Client URLs are designed to be used / embedded in your HTML and therefore are relative to the host and start with a
/.Returns
nullif asset doesn't exist.Subclasses should override
clientUrl()if they do not wish the client URL to be transformed by asset caching strategies like Cold Feet.- clientUrlAbs
virtual Uri? clientUrlAbs()Returns an absolute URL (for example, one that starts with
http://...) using BedSheetServer.toAbsoluteUrl().Returns
nullif asset doesn't exist.- localUrl
abstract Uri? localUrl()The URL relative to the
BedSheetWebMod that corresponds to the asset resource. If your application is the ROOT WebMod then this will be the same asclientUrl; bar any asset caching. If in doubt, use theclientUrlinstead.Returns
nullif asset doesn't exist.- toStr
virtual override Str toStr()Returns
clientUrl.encode()so it may be printed in HTML. Returns the stringnullif the asset doesn't exist.