(
State(state): State<RefRuntimeState>,
Extension(cmd_tx): Extension<Sender<Action>>,
Path(function_name): Path<String>,
req: Request<Body>,
)
| 194 | } |
| 195 | |
| 196 | async fn invoke_handler( |
| 197 | State(state): State<RefRuntimeState>, |
| 198 | Extension(cmd_tx): Extension<Sender<Action>>, |
| 199 | Path(function_name): Path<String>, |
| 200 | req: Request<Body>, |
| 201 | ) -> Result<Response<Body>, ServerError> { |
| 202 | tracing::debug!(%function_name, "invocation received"); |
| 203 | |
| 204 | if function_name == DEFAULT_PACKAGE_FUNCTION && !state.is_default_function_enabled() { |
| 205 | tracing::error!(available_functions = ?state.initial_functions, "the default function route is disabled, use /lambda-url/:function_name to trigger a function call"); |
| 206 | return respond_with_disabled_default_function(&state, true); |
| 207 | } |
| 208 | |
| 209 | if function_name != DEFAULT_PACKAGE_FUNCTION { |
| 210 | if let Err(binaries) = state.is_function_available(&function_name) { |
| 211 | return respond_with_missing_function(&binaries); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | let resp = schedule_invocation(&cmd_tx, function_name, req).await?; |
| 216 | let status_code = resp |
| 217 | .extensions() |
| 218 | .get::<StatusCode>() |
| 219 | .cloned() |
| 220 | .unwrap_or(StatusCode::INTERNAL_SERVER_ERROR); |
| 221 | |
| 222 | let (info, mut body) = resp.into_parts(); |
| 223 | |
| 224 | let mut builder = Response::builder().status(status_code); |
| 225 | |
| 226 | if is_streaming_response(&info.headers) && status_code == StatusCode::OK { |
| 227 | let status = create_streaming_response(&mut builder, &mut body).await?; |
| 228 | builder = builder.status(status); |
| 229 | } |
| 230 | |
| 231 | builder.body(body).map_err(ServerError::ResponseBuild) |
| 232 | } |
| 233 | |
| 234 | async fn invoke_with_response_stream_handler( |
| 235 | State(state): State<RefRuntimeState>, |
nothing calls this directly
no test coverage detected