Ai
1 Star 0 Fork 0

hackerwjz/Golang-audio-chat

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 871 Bytes
一键复制 编辑 原始数据 按行查看 历史
Aldhanekaa 提交于 2022-03-24 21:01 +08:00 . structurise websocet
package main
import (
"encoding/json"
"fmt"
"golang-webchat/server"
"log"
"net/http"
)
func main() {
server.AllRooms.Init()
http.HandleFunc("/create", server.CreateRoomRequestHandler)
http.HandleFunc("/join", server.JoinRoomRequestHandler)
http.HandleFunc("/checkroom", func(w http.ResponseWriter, r *http.Request) {
roomID, ok := r.URL.Query()["roomID"]
if !ok {
log.Println("roomID is missing when want to check room")
json.NewEncoder(w).Encode(struct {
Message string `json:"message"`
}{Message: "roomID is missing when want to check room"})
return
}
if _, ok := server.AllRooms.Map[roomID[0]]; !ok {
fmt.Fprint(w, "not found")
return
}
fmt.Fprint(w, "found")
return
})
log.Println("Starting Server on Port 8000")
err := http.ListenAndServe(":8000", nil)
if err != nil {
log.Fatal("FATAL ERROR : ", err)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hackerwjz/Golang-audio-chat.git
git@gitee.com:hackerwjz/Golang-audio-chat.git
hackerwjz
Golang-audio-chat
Golang-audio-chat
main

搜索帮助