Routing, templating, and database handling
This commit is contained in:
24
routes/getRoutes.go
Normal file
24
routes/getRoutes.go
Normal 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
17
routes/postRoutes.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user