-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 866 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/Luis97lol/auth-service/database"
"github.com/Luis97lol/auth-service/handlers"
"github.com/Luis97lol/auth-service/redis"
"github.com/gorilla/mux"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
// Initialize Redis client
redis.InitRedis()
// Initialize database connection
db, err := database.InitDB()
if err != nil {
log.Fatal("Error initializing database:", err)
}
defer db.Close()
r := mux.NewRouter()
r.HandleFunc("/login", handlers.LoginHandler).Methods("POST")
r.HandleFunc("/validate", handlers.ValidateHandler).Methods("GET")
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
fmt.Printf("Server listening on port %s...\n", port)
log.Fatal(http.ListenAndServe(":"+port, r))
}