portfolio/main.go

26 lines
543 B
Go
Raw Normal View History

2024-02-13 18:45:08 +01:00
package main
import (
"net/http"
"portfolio-backend/api/handler"
"portfolio-backend/database"
)
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()
//connect to database and migrate
database.DB()
2024-02-13 18:45:08 +01:00
// Register the routes and handlers
mux.HandleFunc("/", handler.CatchAllHandler)
mux.HandleFunc("POST /user", handler.CreateUser)
mux.HandleFunc("GET /user/{id}", handler.GetUser)
2024-02-13 18:45:08 +01:00
// Run the server
http.ListenAndServe(":4002", mux)
}