portfolio/main.go
darius 62a7d3b920 DB fix
post user bugfix
create user added
get user added
2024-02-15 15:21:59 +01:00

26 lines
543 B
Go

package main
import (
"net/http"
"portfolio-backend/api/handler"
"portfolio-backend/database"
)
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()
// Register the routes and handlers
mux.HandleFunc("/", handler.CatchAllHandler)
mux.HandleFunc("POST /user", handler.CreateUser)
mux.HandleFunc("GET /user/{id}", handler.GetUser)
// Run the server
http.ListenAndServe(":4002", mux)
}