Return the `RequestOrigin` of the request to determine where the `LambdaRequest` originated from, so that the appropriate response can be selected based on what type of response the request origin expects.
(&self)
| 66 | /// originated from, so that the appropriate response can be selected based on what |
| 67 | /// type of response the request origin expects. |
| 68 | pub fn request_origin(&self) -> RequestOrigin { |
| 69 | match self { |
| 70 | #[cfg(feature = "apigw_rest")] |
| 71 | LambdaRequest::ApiGatewayV1 { .. } => RequestOrigin::ApiGatewayV1, |
| 72 | #[cfg(feature = "apigw_http")] |
| 73 | LambdaRequest::ApiGatewayV2 { .. } => RequestOrigin::ApiGatewayV2, |
| 74 | #[cfg(feature = "alb")] |
| 75 | LambdaRequest::Alb { .. } => RequestOrigin::Alb, |
| 76 | #[cfg(feature = "apigw_websockets")] |
| 77 | LambdaRequest::WebSocket { .. } => RequestOrigin::WebSocket, |
| 78 | #[cfg(feature = "vpc_lattice")] |
| 79 | LambdaRequest::VpcLatticeV2 { .. } => RequestOrigin::VpcLatticeV2, |
| 80 | #[cfg(feature = "pass_through")] |
| 81 | LambdaRequest::PassThrough { .. } => RequestOrigin::PassThrough, |
| 82 | #[cfg(not(any( |
| 83 | feature = "apigw_rest", |
| 84 | feature = "apigw_http", |
| 85 | feature = "alb", |
| 86 | feature = "apigw_websockets", |
| 87 | feature = "vpc_lattice", |
| 88 | )))] |
| 89 | _ => compile_error!("Either feature `apigw_rest`, `apigw_http`, `alb`, `apigw_websockets` or `vpc_lattice` must be enabled for the `lambda-http` crate."), |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /// RequestFuture type |