Files
go-socket/main.go
T
2026-03-30 14:46:31 +02:00

30 lines
742 B
Go

package main
import (
"context"
"log"
"net/http"
)
func withCORS(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
h(w, r)
}
}
func main() {
ctx := context.Background()
DbInit(ctx)
http.HandleFunc("/new/client", withCORS(HttpHandleNewUser))
http.HandleFunc("/new/token", withCORS(HttpHandleNewToken))
http.HandleFunc("/new/group", withCORS(HttpHandeNewGroup))
http.HandleFunc("/mod/group/addclients", withCORS(HttpHandleGroupAddClient))
http.HandleFunc("/new/message", withCORS(HttpHandleNewMessage))
http.HandleFunc("/ws", ServeWsConnection)
log.Println("listening on :8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}