more refactor

This commit is contained in:
wt committed 2025-07-16 14:57:35 +07:00
1 parent 4fde79595e
commit c42a9cd0cf
5 files changed
+83 -48

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
package server
import (
"auth_service/api/auth"
"auth_service/api/users"
"net/http"
"os"
)
func Configure() {
http.HandleFunc("/api/token", auth.Token)
http.HandleFunc("/api/token/verify", auth.VerifyToken)
http.HandleFunc("/api/access", auth.VerifyToken)
if os.Getenv("ENABLE_SELF_REGISTER") == "true" {
http.HandleFunc("/api/register", users.RegisterUser)
}
http.HandleFunc("/api/users", users.GetAllUsers)
http.HandleFunc("/api/users/user", users.GetUser)
http.HandleFunc("/api/users/password", users.ChangePassword)
http.HandleFunc("/api/users/change", users.ChangeUser)
http.HandleFunc("/api/users/del", users.DelUser)
http.HandleFunc("/api/users/add", users.AddUser)
}
+22
View File
@@ -0,0 +1,22 @@
package server
import (
"net/http"
"os"
)
func Run() {
if os.Getenv("ENABLE_TLS") == "true" {
http.ListenAndServeTLS(
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
os.Getenv("CERT_FILE"),
os.Getenv("KEY_FILE"),
nil,
)
} else {
http.ListenAndServe(
os.Getenv("SERVER_ADDRESS")+":"+os.Getenv("SERVER_PORT"),
nil,
)
}
}