-1
这里出了什么问题?我100%确定我正在发送一个HTTP POST请求,但不知何故OR操作符不能按我所期望的那样工作。在第一个例子中,服务器返回405,在第二个例子中代码继续执行。||操作员不按预期方式工作
不工作:
if req.Method != http.MethodPost || req.Method != http.MethodDelete {
http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
return
}
工作:
if req.Method != http.MethodPost {
http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
return
}
看来你需要使用“&&” - 你的病情始终为TRUE – VladimirM
@ tom12e - CONSOLE.LOG您的REG对象,看看Method属性是什么 – Phil