Repository: nushell/nushell
File: crates/nu-command/src/network/http/http_.rs (Rust)

Code before:
    }

    fn search_terms(&self) -> Vec<&str> {
        vec![
            "network", "fetch", "pull", "request", "download", "curl", "wget",
        ]
    }

    fn run(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        call: &Call,
        input: PipelineData,
    ) -> Result<PipelineData, ShellError> {
        let url = call.opt::<Spanned<String>>(engine_state, stack, 0)?;
        let data: Option<Value> = call.opt::<Value>(engine_state, stack, 1)?;

        // prefer stricter calls over aliasing with variables
        if let Some(Spanned { item: method, span }) = &url
            && let method @ ("delete" | "get" | "head" | "options" | "patch" | "post" | "put") =
                method.to_lowercase().as_str()
        {
            return Err(ShellError::GenericError {
                error: "Invalid command construction".into(),
                msg: format!("Using {method:?} dynamically is bad command construction"),
                span: Some(*span),
                help: format!("Prefer to use `http {method}` directly").into(),
                inner: vec![],
            });
        }

        match (url, data) {
            (Some(_), Some(_)) => run_post(engine_state, stack, call, input),
            (Some(_), None) => run_get(engine_state, stack, call, input),
            (None, Some(_)) => Err(ShellError::NushellFailed {
                msg: (String::from("Default verb is get with a payload. Impossible state")),
            }),
            (None, None) => Ok(
                Value::string(get_full_help(self, engine_state, stack), call.head)
                    .into_pipeline_data(),
            ),
        }
    }

    fn examples(&self) -> Vec<Example<'_>> {
        vec![
            Example {
                description: "Get content from example.com with default verb",
                example: "http https://www.example.com",
                result: None,

Review comment (suggestion):
```suggestion
                msg: format!("Using {method:?} dynamically is bad command construction. You are providing it to the `url` positional argument of `http`"),
```

Code after:
    }

    fn search_terms(&self) -> Vec<&str> {
        vec![
            "network", "fetch", "pull", "request", "download", "curl", "wget",
        ]
    }

    fn run(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        call: &Call,
        input: PipelineData,
    ) -> Result<PipelineData, ShellError> {
        let url = call.opt::<Spanned<String>>(engine_state, stack, 0)?;
        let data: Option<Value> = call.opt::<Value>(engine_state, stack, 1)?;

        // prefer stricter calls over aliasing with variables
        if let Some(Spanned { item: method, span }) = &url
            && let method @ ("delete" | "get" | "head" | "options" | "patch" | "post" | "put") =
                method.to_lowercase().as_str()
        {
            return Err(ShellError::GenericError {
                error: "Invalid command construction".into(),
                msg: format!(
                    "Using {method:?} dynamically is bad command construction. You are providing it to the `url` positional argument of `http`"
                ),
                span: Some(*span),
                help: format!("Prefer to use `http {method}` directly").into(),
                inner: vec![],
            });
        }

        match (url, data) {
            (Some(_), Some(_)) => run_post(engine_state, stack, call, input),
            (Some(_), None) => run_get(engine_state, stack, call, input),
            (None, Some(_)) => Err(ShellError::NushellFailed {
                msg: (String::from("Default verb is get with a payload. Impossible state")),
            }),
            (None, None) => Ok(
                Value::string(get_full_help(self, engine_state, stack), call.head)
                    .into_pipeline_data(),
            ),
        }
    }

    fn examples(&self) -> Vec<Example<'_>> {
        vec![
            Example {
                description: "Get content from example.com with default verb",