Routing, templating, and database handling

This commit is contained in:
max
2022-10-20 11:59:33 -05:00
parent 38352de02f
commit e73c006550
10 changed files with 204 additions and 0 deletions

24
routes/getRoutes.go Normal file
View File

@ -0,0 +1,24 @@
package routes
import (
"GoWeb/app"
"GoWeb/controllers"
"log"
"net/http"
)
// GetRoutes defines all project get routes
func GetRoutes(app *app.App) {
// Get controller struct initialize
getController := controllers.GetController{
App: app,
}
// Serve static files
http.Handle("/file/", http.FileServer(http.Dir("./static")))
log.Println("Serving static files from: ./static")
// Pages
http.HandleFunc("/", getController.ShowHome)
http.HandleFunc("/register", getController.ShowRegister)
}

17
routes/postRoutes.go Normal file
View File

@ -0,0 +1,17 @@
package routes
import (
"GoWeb/app"
"GoWeb/controllers"
"net/http"
)
func PostRoutes(app *app.App) {
// Get controller struct initialize
postController := controllers.PostController{
App: app,
}
http.HandleFunc("/register-handle", postController.Register)
http.HandleFunc("/login-handle", postController.Login)
}