Repository: actix/actix-web
File: actix-web-codegen/src/route.rs (Rust)

Code before:
                            "Multiple paths specified! Should be only one!",
                        ));
                    }
                },
                NestedMeta::Meta(syn::Meta::NameValue(nv)) => {
                    if nv.path.is_ident("guard") {
                        if let syn::Lit::Str(lit) = nv.lit {
                            guards.push(Ident::new(&lit.value(), Span::call_site()));
                        } else {
                            return Err(syn::Error::new_spanned(
                                nv.lit,
                                "Attribute guard expects literal string!",
                            ));
                        }
                    } else if nv.path.is_ident("wrap") {
                        if let syn::Lit::Str(lit) = nv.lit {
                            wrappers.push(lit.parse()?);
                        } else {
                            return Err(syn::Error::new_spanned(
                                nv.lit,
                                "Attribute wrap expects type",
                            ));
                        }
                    } else if nv.path.is_ident("method") {
                        if let syn::Lit::Str(ref lit) = nv.lit {
                            match lit.value().to_uppercase().as_str() {
                                "CONNECT" => methods.push(GuardType::Connect),
                                "DELETE" => methods.push(GuardType::Delete),
                                "GET" => methods.push(GuardType::Get),
                                "HEAD" => methods.push(GuardType::Head),
                                "OPTIONS" => methods.push(GuardType::Options),
                                "PATCH" => methods.push(GuardType::Patch),
                                "POST" => methods.push(GuardType::Post),
                                "PUT" => methods.push(GuardType::Put),
                                "TRACE" => methods.push(GuardType::Trace),
                                _ => {
                                    return Err(syn::Error::new_spanned(
                                        &nv.lit,
                                        &format!(
                                            "Unexpected HTTP Method: `{}`",
                                            lit.value()
                                        ),
                                    ))
                                }
                            };
                        } else {
                            return Err(syn::Error::new_spanned(
                                nv.lit,
                                "Attribute method expects literal string!",
                            ));
                        }

Review comment (suggestion):
I don't think that `to_uppercase()` is required. HTTP methods are commonly written in upper case and supporting values such as "cOnNeCt" or "Get" may be confusing.

Code after:
    }
}

struct Args {
    path: syn::LitStr,
    guards: Vec<Ident>,
    wrappers: Vec<syn::Type>,
    methods: HashSet<GuardType>,
}

impl Args {
    fn new(args: AttributeArgs) -> syn::Result<Self> {
        let mut path = None;
        let mut guards = Vec::new();
        let mut wrappers = Vec::new();
        let mut methods = HashSet::new();
        for arg in args {
            match arg {
                NestedMeta::Lit(syn::Lit::Str(lit)) => match path {
                    None => {
                        path = Some(lit);
                    }
                    _ => {
                        return Err(syn::Error::new_spanned(
                            lit,
                            "Multiple paths specified! Should be only one!",
                        ));
                    }
                },
                NestedMeta::Meta(syn::Meta::NameValue(nv)) => {
                    if nv.path.is_ident("guard") {
                        if let syn::Lit::Str(lit) = nv.lit {
                            guards.push(Ident::new(&lit.value(), Span::call_site()));
                        } else {
                            return Err(syn::Error::new_spanned(
                                nv.lit,
                                "Attribute guard expects literal string!",
                            ));
                        }
                    } else if nv.path.is_ident("wrap") {
                        if let syn::Lit::Str(lit) = nv.lit {
                            wrappers.push(lit.parse()?);
                        } else {
                            return Err(syn::Error::new_spanned(
                                nv.lit,
                                "Attribute wrap expects type",
                            ));
                        }
                    } else if nv.path.is_ident("method") {
                        if let syn::Lit::Str(ref lit) = nv.lit {
                            let guard = GuardType::try_from(lit)?;