-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (31 loc) · 1.09 KB
/
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
package main
import (
"log"
"net/http"
"os"
"github.com/joho/godotenv"
"github.com/williamjPriest/HTMXGO/middlewares"
"github.com/williamjPriest/HTMXGO/routes"
)
func main(){
http.HandleFunc("/",routes.MainPageHandler)
http.HandleFunc("/entry",routes.LoginPageHandler)
http.HandleFunc("/login", middlewares.VerifyLogin(routes.LoginHandler) )
http.HandleFunc("/guestLogin",routes.GuestLoginHandler)
http.HandleFunc("/logout",routes.LogoutHandler)
http.HandleFunc("/register", middlewares.VerifyUser(routes.RegisterHandler))
http.HandleFunc("/registerForm", routes.RegisterPageHandler )
http.HandleFunc("/bookmarks", middlewares.VerifyJWT(routes.LoadBookmarksHandler))
http.HandleFunc("/handleBookmarks", middlewares.VerifyJWT(routes.BookmarkHandler))
http.HandleFunc("/checkBookmarks", middlewares.VerifyBookmarks(routes.CheckBookmarkHandler ))
http.HandleFunc("/search", routes.SearchHandler)
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
port := os.Getenv("PORT")
if port == ""{
port = "3000"
}
log.Fatal(http.ListenAndServe("0.0.0.0:"+ port,nil))
}