Struct wasm_service::StaticAssetHandler [−][src]
Serves static assets out of Worker KV storage.
Implementations
impl<'assets> StaticAssetHandler<'assets>
[src]
pub fn init(
index_bin: &'assets [u8],
account_id: &str,
namespace_id: &str,
auth_token: &str
) -> Self
[src]
index_bin: &'assets [u8],
account_id: &str,
namespace_id: &str,
auth_token: &str
) -> Self
Initialize static asset handler
index_bin
is the serialized AssetIndex, which will be deserialized lazily (if needed)
account_id
is Cloudflare account id
namespace_id
is cloudflare KV namespace id (the long hex string, not the friendly name)
auth_token
Cloudflare api OAuth token
pub fn has_asset(&self, req: &Request) -> bool
[src]
Returns true if there is a static asset matching this path. Only checks the manifest - does not check KV. This could give a false positive positive if the manifest is out of date, so site developers must ensure that the manifest is regenerated and pushed if any user deletes static content from KV. That is unlikely to occur if kv-sync is being used to update the manifest and values in the static namespace at the same time.
There is also a potential scenario where this function could return true and the handler later has a network problem reading from KV, or the account credentials are bad, and the end user isn't able to retrieve content for which this method returns true.
Due to these two potential problems, a true result isn't a 100% guarantee that the user will receive content, but in the presence of good deploy practices and reliable networking, this should be accurate.
Trait Implementations
impl<'assets> Handler for StaticAssetHandler<'assets>
[src]
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 Request,
ctx: &'life2 mut Context
) -> Pin<Box<dyn Future<Output = Result<(), HandlerReturn>> + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
req: &'life1 Request,
ctx: &'life2 mut Context
) -> Pin<Box<dyn Future<Output = Result<(), HandlerReturn>> + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Process incoming Request. If no asset was found at the request path, response.is_unset() will be true. Only handles GET and HEAD requests.
Auto Trait Implementations
impl<'assets> !RefUnwindSafe for StaticAssetHandler<'assets>
[src]
impl<'assets> Send for StaticAssetHandler<'assets>
[src]
impl<'assets> !Sync for StaticAssetHandler<'assets>
[src]
impl<'assets> Unpin for StaticAssetHandler<'assets>
[src]
impl<'assets> UnwindSafe for StaticAssetHandler<'assets>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,