猿问

如何检查响应标头是否包含某个字符串

我正在尝试查看location响应标头是否包含字符串queue


这是结构:


if resp.StatusCode >= 200 && resp.StatusCode <= 399 {

        client.CheckRedirect = func(req *http.Request, via []*http.Request) error {

            return errors.New("Redirect")

        }


        if location_headers_here_contains "queue" {

            fmt.Println("queue")

        } else {

            fmt.Println("Nope!")

        }


    }

这样做的正确方法是什么?


慕姐8265434
浏览 169回答 1
1回答

ABOUTYOU

利用if strings.Contains(resp.Header.Get("Location"),"queue") {&nbsp; fmt.Println("queue")} else {&nbsp; fmt.Println("Nope!")}
随时随地看视频慕课网APP

相关分类

Go
我要回答