http.HandleFunc 向客户端请求数据。有没有办法以某种方式指定此方法只能通过 GET 或 POST 工作?
http.HandleFunc("/olock_open/all", func(w http.ResponseWriter, r *http.Request) {
username, password, ok := r.BasicAuth()
check_auth := authfunc.CheckAuth(w, username, password, ok)
if !check_auth {
return
}
for i := 0; i < len(online_locks_list_active); i++ {
_, err := tcpcommandolock.SendCommandOlock(online_locks_list_active[i].Connection, []byte{0x02, 0x0A, 0x30, 0x51, 0x03, 0x90})
if err != nil {
syslogging.LogToSys("Error, can't send command to BU"+online_locks_list_active[i].Address+": "+err.Error(), "Info")
}
}
defer r.Body.Close()
})```