| 315 | } |
| 316 | |
| 317 | async fn get_http_integration( |
| 318 | &self, |
| 319 | request: Request<api::GetHttpIntegrationRequest>, |
| 320 | ) -> Result<Response<api::GetHttpIntegrationResponse>, Status> { |
| 321 | let req = request.get_ref(); |
| 322 | let app_id = Uuid::from_str(&req.application_id).map_err(|e| e.status())?; |
| 323 | |
| 324 | self.validator |
| 325 | .validate( |
| 326 | request.extensions(), |
| 327 | validator::ValidateApplicationAccess::new(validator::Flag::Read, app_id), |
| 328 | ) |
| 329 | .await?; |
| 330 | |
| 331 | let i = application::get_integration(&app_id, application::IntegrationKind::Http) |
| 332 | .await |
| 333 | .map_err(|e| e.status())?; |
| 334 | |
| 335 | if let application::IntegrationConfiguration::Http(conf) = &i.configuration { |
| 336 | let mut resp = Response::new(api::GetHttpIntegrationResponse { |
| 337 | integration: Some(api::HttpIntegration { |
| 338 | application_id: app_id.to_string(), |
| 339 | headers: conf.headers.clone(), |
| 340 | encoding: match conf.json { |
| 341 | true => api::Encoding::Json, |
| 342 | false => api::Encoding::Protobuf, |
| 343 | } |
| 344 | .into(), |
| 345 | event_endpoint_url: conf.event_endpoint_url.clone(), |
| 346 | }), |
| 347 | }); |
| 348 | resp.metadata_mut() |
| 349 | .insert("x-log-application_id", req.application_id.parse().unwrap()); |
| 350 | |
| 351 | Ok(resp) |
| 352 | } else { |
| 353 | Err(Status::internal("Integration has no Http configuration")) |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | async fn update_http_integration( |
| 358 | &self, |