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() PgInit(ctx) http.HandleFunc("/new/user", withCORS(HttpHandleUserNew)) http.HandleFunc("/new/connection", withCORS(HttpHandleUserNewConnection)) http.HandleFunc("/new/token", withCORS(HttpHandleUserNewToken)) http.HandleFunc("/mod/user/appearence", withCORS(HttpHandleUserModifyAppearance)) http.HandleFunc("/mod/user/about", withCORS(HttpHandleUserModifyAbout)) http.HandleFunc("/mod/connection/accept", withCORS(HttpHandleUserElevateConnection)) http.HandleFunc("/get/connections", withCORS(HttpHandleUserGetConnections)) http.HandleFunc("/get/connection/messages", withCORS(HttpHandleUserGetConnectionMessages)) http.HandleFunc("/del/user", withCORS(HttpHandleUserDelete)) http.HandleFunc("/del/connection", withCORS(HttpHandleUserDeleteConnection)) http.HandleFunc("/msg/user", withCORS(HttpHandleDm)) http.HandleFunc("/ws", ServeWsConnection) log.Println("listening on :8080") log.Fatal(http.ListenAndServe(":8080", nil)) }