pub struct X402LayerBuilder<TSource, TFacilitator> { /* private fields */ }Available on crate feature
server only.Expand description
Builder for configuring the X402 middleware layer.
Generic over TSource which implements PriceTagSource to support
both static and dynamic pricing strategies.
Implementations§
Source§impl<TFacilitator> X402LayerBuilder<StaticPriceTags, TFacilitator>
impl<TFacilitator> X402LayerBuilder<StaticPriceTags, TFacilitator>
Sourcepub fn with_price_tag(self, price_tag: PriceTag) -> Self
pub fn with_price_tag(self, price_tag: PriceTag) -> Self
Adds another payment option.
Allows specifying multiple accepted payment methods (e.g., different networks).
Note: This method is only available for static price tag sources.
Source§impl<TSource, TFacilitator> X402LayerBuilder<TSource, TFacilitator>
impl<TSource, TFacilitator> X402LayerBuilder<TSource, TFacilitator>
Sourcepub fn with_description(self, description: String) -> Self
pub fn with_description(self, description: String) -> Self
Sets a description of what the payment grants access to.
This is included in 402 responses to inform clients what they’re paying for.
Sourcepub fn with_mime_type(self, mime: String) -> Self
pub fn with_mime_type(self, mime: String) -> Self
Sets the MIME type of the protected resource.
Defaults to application/json if not specified.
Sourcepub fn with_resource(self, resource: Url) -> Self
pub fn with_resource(self, resource: Url) -> Self
Sets the full URL of the protected resource.
When set, this URL is used directly instead of constructing it from the base URL and request URI. This is the preferred approach in production.
Trait Implementations§
Source§impl<TSource: Clone, TFacilitator: Clone> Clone for X402LayerBuilder<TSource, TFacilitator>
impl<TSource: Clone, TFacilitator: Clone> Clone for X402LayerBuilder<TSource, TFacilitator>
Source§fn clone(&self) -> X402LayerBuilder<TSource, TFacilitator>
fn clone(&self) -> X402LayerBuilder<TSource, TFacilitator>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<S, TSource, TFacilitator> Layer<S> for X402LayerBuilder<TSource, TFacilitator>where
S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + Sync + 'static,
S::Future: Send + 'static,
TFacilitator: Facilitator + Clone,
TSource: PriceTagSource,
impl<S, TSource, TFacilitator> Layer<S> for X402LayerBuilder<TSource, TFacilitator>where
S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + Sync + 'static,
S::Future: Send + 'static,
TFacilitator: Facilitator + Clone,
TSource: PriceTagSource,
Auto Trait Implementations§
impl<TSource, TFacilitator> Freeze for X402LayerBuilder<TSource, TFacilitator>
impl<TSource, TFacilitator> RefUnwindSafe for X402LayerBuilder<TSource, TFacilitator>where
TFacilitator: RefUnwindSafe,
TSource: RefUnwindSafe,
impl<TSource, TFacilitator> Send for X402LayerBuilder<TSource, TFacilitator>
impl<TSource, TFacilitator> Sync for X402LayerBuilder<TSource, TFacilitator>
impl<TSource, TFacilitator> Unpin for X402LayerBuilder<TSource, TFacilitator>
impl<TSource, TFacilitator> UnwindSafe for X402LayerBuilder<TSource, TFacilitator>where
TFacilitator: UnwindSafe,
TSource: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more