Parse a Bedrock invocation path into its `(model_id, action_suffix, query_tail)` components. Recognized shape (caller's path on the way into the router): - `/model/ /invoke[? ]` → action `/invoke` ` ` must be non-empty and contain no `/`. The query tail (including the leading `?`) is preserved so [`rewrite_bedrock_path`] can restore it; the L7 matcher accepts
(path: &str)
| 867 | /// event-stream error termination; the L7 pattern set does not |
| 868 | /// advertise it today, so it cannot reach this parser. |
| 869 | fn parse_bedrock_invocation_path(path: &str) -> Option<(&str, &'static str, &str)> { |
| 870 | // Slice up to but not including `?`, then keep the `?`-prefixed |
| 871 | // tail so callers can re-attach it without reconstructing the |
| 872 | // delimiter. |
| 873 | let (path_only, query_tail) = path |
| 874 | .find('?') |
| 875 | .map_or((path, ""), |idx| (&path[..idx], &path[idx..])); |
| 876 | let rest = path_only.strip_prefix("/model/")?; |
| 877 | let slash_at = rest.find('/')?; |
| 878 | if slash_at == 0 { |
| 879 | return None; |
| 880 | } |
| 881 | let model_id = &rest[..slash_at]; |
| 882 | let suffix = &rest[slash_at..]; |
| 883 | let action: &'static str = match suffix { |
| 884 | "/invoke" => "/invoke", |
| 885 | _ => return None, |
| 886 | }; |
| 887 | Some((model_id, action, query_tail)) |
| 888 | } |
| 889 | |
| 890 | /// Rewrite a Bedrock invocation path so the model segment is the |
| 891 | /// operator-configured `route.model` rather than whatever the caller |
no outgoing calls