2024-02-13 18:45:08 +01:00
|
|
|
package main
|
|
|
|
|
|
2024-02-14 14:55:41 +01:00
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
"portfolio-backend/database"
|
|
|
|
|
|
|
|
|
|
"portfolio-backend/api/handler"
|
|
|
|
|
)
|
2024-02-13 18:45:08 +01:00
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
|
|
// Create a new request multiplexer
|
|
|
|
|
// Take incoming requests and dispatch them to the matching handlers
|
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
|
|
2024-02-14 00:08:14 +01:00
|
|
|
//connect to database and migrate
|
2024-02-14 14:55:41 +01:00
|
|
|
database.DB()
|
2024-02-14 00:08:14 +01:00
|
|
|
|
2024-02-13 18:45:08 +01:00
|
|
|
// Register the routes and handlers
|
2024-02-14 14:55:41 +01:00
|
|
|
mux.HandleFunc("/", handler.CatchAllHandler)
|
|
|
|
|
mux.HandleFunc("/test", handler.TestHandler)
|
|
|
|
|
mux.HandleFunc("/test2", handler.Test2Handler)
|
2024-02-13 18:45:08 +01:00
|
|
|
|
|
|
|
|
// Run the server
|
|
|
|
|
http.ListenAndServe(":4002", mux)
|
|
|
|
|
}
|