web_push::request_builder

Function build_request

Source
pub fn build_request<T>(message: WebPushMessage) -> Request<T>
where T: From<Vec<u8>> + From<&'static str>,
Expand description

Builds the request to send to the push service.

This function is generic over the request body, this means that you can swap out client implementations even if they use different body types.

ยงExample

let info = SubscriptionInfo::new(
 "http://google.com",
 "BLMbF9ffKBiWQLCKvTHb6LO8Nb6dcUh6TItC455vu2kElga6PQvUmaFyCdykxY2nOSSL3yKgfbmFLRTUaGv4yV8",
 "xS03Fi5ErfTNH_l9WHE9Ig",
 );

 let mut builder = WebPushMessageBuilder::new(&info).unwrap();

 //Build the request for isahc
 let request = build_request::<isahc::Body>(builder.build().unwrap());
 //Send using a http client