working file sharing
This commit is contained in:
@@ -5,7 +5,8 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
http2 "go-socket/packages/http"
|
||||
"go-socket/packages/httpRequest"
|
||||
"go-socket/packages/minio"
|
||||
"go-socket/packages/postgresql"
|
||||
"go-socket/packages/wsServer"
|
||||
)
|
||||
@@ -13,6 +14,11 @@ import (
|
||||
func withCORS(h http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "token, Content-Type")
|
||||
if r.Method == http.MethodOptions {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
h(w, r)
|
||||
}
|
||||
}
|
||||
@@ -20,21 +26,24 @@ func withCORS(h http.HandlerFunc) http.HandlerFunc {
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
postgresql.Init(ctx)
|
||||
minio.Init(ctx)
|
||||
|
||||
http.HandleFunc("/new/user", withCORS(http2.HandleUserNew))
|
||||
http.HandleFunc("/new/connection", withCORS(http2.HandleUserNewConnection))
|
||||
http.HandleFunc("/new/token", withCORS(http2.HandleUserNewToken))
|
||||
http.HandleFunc("/mod/user/appearence", withCORS(http2.HandleUserModifyAppearance))
|
||||
http.HandleFunc("/mod/user/about", withCORS(http2.HandleUserModifyAbout))
|
||||
http.HandleFunc("/mod/connection/accept", withCORS(http2.HandleUserElevateConnection))
|
||||
http.HandleFunc("/new/user", withCORS(httpRequest.HandleUserNew))
|
||||
http.HandleFunc("/new/connection", withCORS(httpRequest.HandleUserNewConnection))
|
||||
http.HandleFunc("/new/token", withCORS(httpRequest.HandleUserNewToken))
|
||||
http.HandleFunc("/new/file", withCORS(httpRequest.HandleFileUpload))
|
||||
http.HandleFunc("/mod/user/appearence", withCORS(httpRequest.HandleUserModifyAppearance))
|
||||
http.HandleFunc("/mod/user/about", withCORS(httpRequest.HandleUserModifyAbout))
|
||||
http.HandleFunc("/mod/connection/accept", withCORS(httpRequest.HandleUserElevateConnection))
|
||||
|
||||
http.HandleFunc("/get/connections", withCORS(http2.HandleUserGetConnections))
|
||||
http.HandleFunc("/get/connection/messages", withCORS(http2.HandleUserGetConnectionMessages))
|
||||
http.HandleFunc("/get/connections", withCORS(httpRequest.HandleUserGetConnections))
|
||||
http.HandleFunc("/get/connection/messages", withCORS(httpRequest.HandleUserGetConnectionMessages))
|
||||
http.HandleFunc("/get/file", withCORS(httpRequest.HandleFileDownload))
|
||||
|
||||
http.HandleFunc("/del/user", withCORS(http2.HandleUserDelete))
|
||||
http.HandleFunc("/del/connection", withCORS(http2.HandleUserDeleteConnection))
|
||||
http.HandleFunc("/del/user", withCORS(httpRequest.HandleUserDelete))
|
||||
http.HandleFunc("/del/connection", withCORS(httpRequest.HandleUserDeleteConnection))
|
||||
|
||||
http.HandleFunc("/msg/user", withCORS(http2.HandleDm))
|
||||
http.HandleFunc("/msg/user", withCORS(httpRequest.HandleDm))
|
||||
http.HandleFunc("/ws", wsServer.ServeWsConnection)
|
||||
|
||||
log.Println("listening on :8080")
|
||||
|
||||
Reference in New Issue
Block a user