(&mut self, directive: Directive)
| 87 | |
| 88 | impl RouteAnnotation { |
| 89 | pub fn parse_directive(&mut self, directive: Directive) -> Result<(), String> { |
| 90 | match directive.name.as_str() { |
| 91 | "auth" | "basic_auth" => { |
| 92 | if matches!(self.auth, Auth::None) { |
| 93 | self.auth = Auth::from_directive(directive)?; |
| 94 | } else { |
| 95 | return Err("Duplicate auth directive".into()); |
| 96 | } |
| 97 | } |
| 98 | "docs" => { |
| 99 | if self.docs.is_some() { |
| 100 | return Err("Duplicate @docs directive".into()); |
| 101 | } else { |
| 102 | self.docs = Some(Docs::from_directive(directive)?); |
| 103 | } |
| 104 | } |
| 105 | "sso" => { |
| 106 | if let Some(Value::String(provider)) = directive.get_arg_value("provider") { |
| 107 | self.sso_provider = Some(SsoProvider::try_from(provider)?); |
| 108 | } else { |
| 109 | return Err("@sso required 'provider' argument.".into()); |
| 110 | } |
| 111 | } |
| 112 | _ => { |
| 113 | return Err(format!("Invalid directive: @{}", directive.name)); |
| 114 | } |
| 115 | } |
| 116 | Ok(()) |
| 117 | } |
| 118 | } |
nothing calls this directly
no test coverage detected