Integrate recoverable native purchases, registered rentals and explicit payment consent
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
mod purchase;
|
||||
mod cloud_purchase;
|
||||
mod blob;
|
||||
mod cdp;
|
||||
mod content;
|
||||
mod registered_media;
|
||||
mod rental_playback;
|
||||
mod dwn;
|
||||
mod model_proxy;
|
||||
mod node_message;
|
||||
@@ -385,6 +388,10 @@ impl ApiHandler {
|
||||
let path = req.uri().path().to_string();
|
||||
let method = req.method().clone();
|
||||
|
||||
if path.starts_with("/api/rental-playback/") {
|
||||
return self.handle_local_rental_request(&method, &path, req.headers()).await;
|
||||
}
|
||||
|
||||
// Handle CORS preflight for all routes
|
||||
if method == Method::OPTIONS {
|
||||
let mut builder = Response::builder()
|
||||
@@ -445,6 +452,14 @@ impl ApiHandler {
|
||||
.await;
|
||||
}
|
||||
|
||||
// Purchase routes bound the original body before the generic buffer.
|
||||
if method == Method::POST && matches!(path.as_str(),
|
||||
crate::content_purchase_protocol::OFFER_ROUTE | crate::content_purchase_protocol::ACCEPT_ROUTE
|
||||
| crate::content_purchase_protocol::SETTLE_ROUTE | crate::content_purchase_protocol::STATUS_ROUTE
|
||||
| crate::content_purchase_protocol::CANCEL_ROUTE) {
|
||||
return self.handle_purchase_request(req).await;
|
||||
}
|
||||
|
||||
// Convert body to bytes for non-WS routes
|
||||
let headers = req.headers().clone();
|
||||
let query_string = req.uri().query().map(|s| s.to_string()).unwrap_or_default();
|
||||
@@ -587,6 +602,9 @@ impl ApiHandler {
|
||||
|
||||
// Immutable registered rentals use durable seller receipts and their
|
||||
// first-open window, never legacy mutable filename shares.
|
||||
(Method::GET, p) if p.starts_with("/content/") && p.contains("/purchase/") => {
|
||||
self.handle_cloud_purchase(p, &headers).await
|
||||
}
|
||||
(Method::GET, p) if p.starts_with("/content/registered_") && p.contains("/rental/") => {
|
||||
self.handle_registered_rental(p, &headers).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user