-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (27 loc) · 1.07 KB
/
Copy pathmain.go
File metadata and controls
40 lines (27 loc) · 1.07 KB
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
package main
import (
"log"
"net/http"
handler "stage/internals/handlers" // Ensure this matches your actual package name
"stage/internals/repository"
"stage/internals/service"
"github.com/gorilla/mux" // You must import the package
)
func main() {
repo := repository.NewMemoryRepository()
authService := service.NewAuthService(repo)
authHandler := handler.NewAuthHandler(authService)
// Initialize the gorilla/mux router
r := mux.NewRouter()
fs := http.FileServer(http.Dir("./static"))
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fs))
// Routes
r.HandleFunc("/", authHandler.HomePage).Methods(http.MethodGet)
r.HandleFunc("/register", authHandler.RegisterPage).Methods(http.MethodGet)
r.HandleFunc("/login", authHandler.LoginPage).Methods(http.MethodGet)
r.HandleFunc("/register", authHandler.Register).Methods(http.MethodPost)
r.HandleFunc("/login", authHandler.Login).Methods(http.MethodPost)
r.HandleFunc("/dashboard", authHandler.DashboardPage).Methods(http.MethodGet)
log.Println("running on :8080")
http.ListenAndServe(":8080", r)
}