Encode and compress sync response
(response: &SyncResponse)
| 53 | |
| 54 | /// Encode and compress sync response |
| 55 | fn encode_sync_response(response: &SyncResponse) -> Result<Vec<u8>, Status> { |
| 56 | let encoded = encode(response).map_err(|e| { |
| 57 | warn!("failed to encode sync response: {e}"); |
| 58 | Status::InternalServerError |
| 59 | })?; |
| 60 | |
| 61 | // Compress |
| 62 | let mut encoder = GzEncoder::new(Vec::new(), Compression::fast()); |
| 63 | encoder.write_all(&encoded).map_err(|e| { |
| 64 | warn!("failed to compress sync response: {e}"); |
| 65 | Status::InternalServerError |
| 66 | })?; |
| 67 | encoder.finish().map_err(|e| { |
| 68 | warn!("failed to finish compression: {e}"); |
| 69 | Status::InternalServerError |
| 70 | }) |
| 71 | } |
| 72 | |
| 73 | /// Verify that the request is from a gateway with the same app_id (mTLS verification) |
| 74 | fn verify_gateway_peer(state: &Proxy, cert: Option<Certificate<'_>>) -> Result<(), Status> { |
no test coverage detected